Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 006dbfc

Browse files
author
Chris Yang
authored
Always keep thread merged when there are platform views. (#18245)
1 parent 2f8495a commit 006dbfc

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -251,22 +251,21 @@
251251
composition_order_ = active_composition_order_;
252252
}
253253

254-
bool FlutterPlatformViewsController::HasPendingViewOperations() {
255-
if (!views_to_dispose_.empty()) {
256-
return true;
257-
}
258-
if (!views_to_recomposite_.empty()) {
259-
return true;
260-
}
261-
return active_composition_order_ != composition_order_;
254+
// TODO(cyanglaz): https://github.com/flutter/flutter/issues/56474
255+
// Make this method check if there are pending view operations instead.
256+
// Also rename it to `HasPendingViewOperations`.
257+
bool FlutterPlatformViewsController::HasPlatformViewThisOrNextFrame() {
258+
return composition_order_.size() > 0 || active_composition_order_.size() > 0;
262259
}
263260

264261
const int FlutterPlatformViewsController::kDefaultMergedLeaseDuration;
265262

266263
PostPrerollResult FlutterPlatformViewsController::PostPrerollAction(
267264
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) {
268-
const bool uiviews_mutated = HasPendingViewOperations();
269-
if (uiviews_mutated) {
265+
// TODO(cyanglaz): https://github.com/flutter/flutter/issues/56474
266+
// Rename `has_platform_view` to `view_mutated` when the above issue is resolved.
267+
const bool has_platform_view = HasPlatformViewThisOrNextFrame();
268+
if (has_platform_view) {
270269
if (raster_thread_merger->IsMerged()) {
271270
raster_thread_merger->ExtendLeaseTo(kDefaultMergedLeaseDuration);
272271
} else {
@@ -485,7 +484,7 @@
485484
// Any UIKit related code has to run on main thread.
486485
// When on a non-main thread, we only allow the rest of the method to run if there is no
487486
// Pending UIView operations.
488-
FML_DCHECK([[NSThread currentThread] isMainThread] || !HasPendingViewOperations());
487+
FML_DCHECK([[NSThread currentThread] isMainThread] || !HasPlatformViewThisOrNextFrame());
489488

490489
DisposeViews();
491490

shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,12 @@ class FlutterPlatformViewsController {
242242
// Dispose the views in `views_to_dispose_`.
243243
void DisposeViews();
244244

245-
// This will return true after pre-roll if any of the embedded views
246-
// have mutated for last layer tree.
247-
bool HasPendingViewOperations();
245+
// Returns true if there are embedded views in the scene at current frame
246+
// Or there will be embedded views in the next frame.
247+
// TODO(cyanglaz): https://github.com/flutter/flutter/issues/56474
248+
// Make this method check if there are pending view operations instead.
249+
// Also rename it to `HasPendingViewOperations`.
250+
bool HasPlatformViewThisOrNextFrame();
248251

249252
// Traverse the `mutators_stack` and return the number of clip operations.
250253
int CountClips(const MutatorsStack& mutators_stack);

0 commit comments

Comments
 (0)