Always keep thread merged when there are platform views. (#18245)

This commit is contained in:
Chris Yang 2020-05-13 08:53:46 -07:00 committed by GitHub
parent 2f8495a5e6
commit 006dbfce2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 14 deletions

View File

@ -251,22 +251,21 @@ void FlutterPlatformViewsController::CancelFrame() {
composition_order_ = active_composition_order_;
}
bool FlutterPlatformViewsController::HasPendingViewOperations() {
if (!views_to_dispose_.empty()) {
return true;
}
if (!views_to_recomposite_.empty()) {
return true;
}
return active_composition_order_ != composition_order_;
// TODO(cyanglaz): https://github.com/flutter/flutter/issues/56474
// Make this method check if there are pending view operations instead.
// Also rename it to `HasPendingViewOperations`.
bool FlutterPlatformViewsController::HasPlatformViewThisOrNextFrame() {
return composition_order_.size() > 0 || active_composition_order_.size() > 0;
}
const int FlutterPlatformViewsController::kDefaultMergedLeaseDuration;
PostPrerollResult FlutterPlatformViewsController::PostPrerollAction(
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) {
const bool uiviews_mutated = HasPendingViewOperations();
if (uiviews_mutated) {
// TODO(cyanglaz): https://github.com/flutter/flutter/issues/56474
// Rename `has_platform_view` to `view_mutated` when the above issue is resolved.
const bool has_platform_view = HasPlatformViewThisOrNextFrame();
if (has_platform_view) {
if (raster_thread_merger->IsMerged()) {
raster_thread_merger->ExtendLeaseTo(kDefaultMergedLeaseDuration);
} else {
@ -485,7 +484,7 @@ bool FlutterPlatformViewsController::SubmitFrame(GrContext* gr_context,
// Any UIKit related code has to run on main thread.
// When on a non-main thread, we only allow the rest of the method to run if there is no
// Pending UIView operations.
FML_DCHECK([[NSThread currentThread] isMainThread] || !HasPendingViewOperations());
FML_DCHECK([[NSThread currentThread] isMainThread] || !HasPlatformViewThisOrNextFrame());
DisposeViews();

View File

@ -242,9 +242,12 @@ class FlutterPlatformViewsController {
// Dispose the views in `views_to_dispose_`.
void DisposeViews();
// This will return true after pre-roll if any of the embedded views
// have mutated for last layer tree.
bool HasPendingViewOperations();
// Returns true if there are embedded views in the scene at current frame
// Or there will be embedded views in the next frame.
// TODO(cyanglaz): https://github.com/flutter/flutter/issues/56474
// Make this method check if there are pending view operations instead.
// Also rename it to `HasPendingViewOperations`.
bool HasPlatformViewThisOrNextFrame();
// Traverse the `mutators_stack` and return the number of clip operations.
int CountClips(const MutatorsStack& mutators_stack);