diff --git a/engine/src/flutter/flow/embedded_views.h b/engine/src/flutter/flow/embedded_views.h index 50d09ed928..1b641665e3 100644 --- a/engine/src/flutter/flow/embedded_views.h +++ b/engine/src/flutter/flow/embedded_views.h @@ -187,6 +187,10 @@ class ExternalViewEmbedder { // have mutated for last layer tree. virtual bool HasPendingViewOperations() = 0; + // Call this in-lieu of |SubmitFrame| to clear pre-roll state and + // sets the stage for the next pre-roll. + virtual void CancelFrame() = 0; + virtual void BeginFrame(SkISize frame_size) = 0; virtual void PrerollCompositeEmbeddedView( diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index aa2e2ab0bf..33c5332baa 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -160,6 +160,10 @@ void FlutterPlatformViewsController::SetFrameSize(SkISize frame_size) { frame_size_ = frame_size; } +void FlutterPlatformViewsController::CancelFrame() { + composition_order_.clear(); +} + bool FlutterPlatformViewsController::HasPendingViewOperations() { if (!views_to_recomposite_.empty()) { return true; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h index 40ea6333df..9644682c91 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h @@ -81,6 +81,8 @@ class FlutterPlatformViewsController { bool HasPendingViewOperations(); + void CancelFrame(); + void PrerollCompositeEmbeddedView(int view_id, std::unique_ptr params); diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_gl.h b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_gl.h index 8999669c6a..eb1bf4a61c 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_gl.h +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_gl.h @@ -51,6 +51,9 @@ class IOSSurfaceGL final : public IOSSurface, // |GPUSurfaceGLDelegate| flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override; + // |flutter::ExternalViewEmbedder| + void CancelFrame() override; + // |flutter::ExternalViewEmbedder| bool HasPendingViewOperations() override; diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_gl.mm b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_gl.mm index 5f4185a07b..aaad611905 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_gl.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_gl.mm @@ -82,6 +82,15 @@ flutter::ExternalViewEmbedder* IOSSurfaceGL::GetExternalViewEmbedder() { } } +void IOSSurfaceGL::CancelFrame() { + FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); + FML_CHECK(platform_views_controller != nullptr); + platform_views_controller->CancelFrame(); + // Committing the current transaction as |BeginFrame| will create a nested + // CATransaction otherwise. + [CATransaction commit]; +} + bool IOSSurfaceGL::HasPendingViewOperations() { FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); FML_CHECK(platform_views_controller != nullptr); diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_software.h b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_software.h index 7b0c2a0b0d..29d3ad7eae 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_software.h +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_software.h @@ -45,6 +45,9 @@ class IOSSurfaceSoftware final : public IOSSurface, // |GPUSurfaceSoftwareDelegate| flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override; + // |flutter::ExternalViewEmbedder| + void CancelFrame() override; + // |flutter::ExternalViewEmbedder| bool HasPendingViewOperations() override; diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_software.mm b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_software.mm index 2977ed792c..30818eb7ff 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_software.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_software.mm @@ -135,6 +135,12 @@ flutter::ExternalViewEmbedder* IOSSurfaceSoftware::GetExternalViewEmbedder() { } } +void IOSSurfaceSoftware::CancelFrame() { + FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); + FML_CHECK(platform_views_controller != nullptr); + platform_views_controller->CancelFrame(); +} + bool IOSSurfaceSoftware::HasPendingViewOperations() { FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); FML_CHECK(platform_views_controller != nullptr);