Skip to content

Commit 791143f

Browse files
authored
ExternalViewEmbedder can CancelFrame after pre-roll (#9660)
* ExternalViewEmbedder can CancelFrame after pre-roll - Resets the state so next pre-roll can be successful. - Commit any pending `CATransaction` so we don't create nested transactions. * Update flow/embedded_views.h
1 parent d637f29 commit 791143f

File tree

7 files changed

+31
-0
lines changed

7 files changed

+31
-0
lines changed

flow/embedded_views.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ class ExternalViewEmbedder {
187187
// have mutated for last layer tree.
188188
virtual bool HasPendingViewOperations() = 0;
189189

190+
// Call this in-lieu of |SubmitFrame| to clear pre-roll state and
191+
// sets the stage for the next pre-roll.
192+
virtual void CancelFrame() = 0;
193+
190194
virtual void BeginFrame(SkISize frame_size) = 0;
191195

192196
virtual void PrerollCompositeEmbeddedView(

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@
160160
frame_size_ = frame_size;
161161
}
162162

163+
void FlutterPlatformViewsController::CancelFrame() {
164+
composition_order_.clear();
165+
}
166+
163167
bool FlutterPlatformViewsController::HasPendingViewOperations() {
164168
if (!views_to_recomposite_.empty()) {
165169
return true;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class FlutterPlatformViewsController {
8181

8282
bool HasPendingViewOperations();
8383

84+
void CancelFrame();
85+
8486
void PrerollCompositeEmbeddedView(int view_id,
8587
std::unique_ptr<flutter::EmbeddedViewParams> params);
8688

shell/platform/darwin/ios/ios_surface_gl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class IOSSurfaceGL final : public IOSSurface,
5151
// |GPUSurfaceGLDelegate|
5252
flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override;
5353

54+
// |flutter::ExternalViewEmbedder|
55+
void CancelFrame() override;
56+
5457
// |flutter::ExternalViewEmbedder|
5558
bool HasPendingViewOperations() override;
5659

shell/platform/darwin/ios/ios_surface_gl.mm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@
8282
}
8383
}
8484

85+
void IOSSurfaceGL::CancelFrame() {
86+
FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController();
87+
FML_CHECK(platform_views_controller != nullptr);
88+
platform_views_controller->CancelFrame();
89+
// Committing the current transaction as |BeginFrame| will create a nested
90+
// CATransaction otherwise.
91+
[CATransaction commit];
92+
}
93+
8594
bool IOSSurfaceGL::HasPendingViewOperations() {
8695
FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController();
8796
FML_CHECK(platform_views_controller != nullptr);

shell/platform/darwin/ios/ios_surface_software.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class IOSSurfaceSoftware final : public IOSSurface,
4545
// |GPUSurfaceSoftwareDelegate|
4646
flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override;
4747

48+
// |flutter::ExternalViewEmbedder|
49+
void CancelFrame() override;
50+
4851
// |flutter::ExternalViewEmbedder|
4952
bool HasPendingViewOperations() override;
5053

shell/platform/darwin/ios/ios_surface_software.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@
135135
}
136136
}
137137

138+
void IOSSurfaceSoftware::CancelFrame() {
139+
FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController();
140+
FML_CHECK(platform_views_controller != nullptr);
141+
platform_views_controller->CancelFrame();
142+
}
143+
138144
bool IOSSurfaceSoftware::HasPendingViewOperations() {
139145
FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController();
140146
FML_CHECK(platform_views_controller != nullptr);

0 commit comments

Comments
 (0)