diff --git a/flow/embedded_views.h b/flow/embedded_views.h index e98c98a6e1cc7..81c67de9784b5 100644 --- a/flow/embedded_views.h +++ b/flow/embedded_views.h @@ -27,7 +27,7 @@ class ExternalViewEmbedder { public: ExternalViewEmbedder() = default; - virtual void SetFrameSize(SkISize frame_size) = 0; + virtual void BeginFrame(SkISize frame_size) = 0; virtual void PrerollCompositeEmbeddedView(int view_id) = 0; diff --git a/shell/common/rasterizer.cc b/shell/common/rasterizer.cc index 29d534b2a4430..9e30a4c561a4e 100644 --- a/shell/common/rasterizer.cc +++ b/shell/common/rasterizer.cc @@ -165,7 +165,7 @@ bool Rasterizer::DrawToSurface(flow::LayerTree& layer_tree) { auto external_view_embedder = surface_->GetExternalViewEmbedder(); if (external_view_embedder != nullptr) { - external_view_embedder->SetFrameSize(layer_tree.frame_size()); + external_view_embedder->BeginFrame(layer_tree.frame_size()); } auto compositor_frame = compositor_context_->AcquireFrame( diff --git a/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.mm b/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.mm index 6b7d8bbf093e5..83f59d24e0b81 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.mm @@ -71,6 +71,11 @@ + (Class)layerClass { - (std::unique_ptr)createGLSurfaceWithContext: (std::shared_ptr)gl_context { fml::scoped_nsobject eagl_layer(reinterpret_cast([self.layer retain])); + // TODO(amirh): We can lower this to iOS 8.0 once we have a Metal rendering backend. + // https://github.com/flutter/flutter/issues/24132 + if (@available(iOS 9.0, *)) { + eagl_layer.get().presentsWithTransaction = YES; + } return std::make_unique(eagl_layer, std::move(gl_context)); } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterView.mm b/shell/platform/darwin/ios/framework/Source/FlutterView.mm index fbf3270925828..f60f114f2ea1c 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterView.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterView.mm @@ -79,6 +79,15 @@ + (Class)layerClass { if ([self.layer isKindOfClass:[CAEAGLLayer class]]) { fml::scoped_nsobject eagl_layer( reinterpret_cast([self.layer retain])); + if (shell::IsIosEmbeddedViewsPreviewEnabled()) { + // TODO(amirh): We can lower this to iOS 8.0 once we have a Metal rendering backend. + // https://github.com/flutter/flutter/issues/24132 + if (@available(iOS 9.0, *)) { + // TODO(amirh): only do this if there's an embedded view. + // https://github.com/flutter/flutter/issues/24133 + eagl_layer.get().presentsWithTransaction = YES; + } + } return std::make_unique(std::move(eagl_layer), [_delegate platformViewsController]); } else { diff --git a/shell/platform/darwin/ios/ios_surface_gl.h b/shell/platform/darwin/ios/ios_surface_gl.h index f0e898a1bb00e..9f7013c29b100 100644 --- a/shell/platform/darwin/ios/ios_surface_gl.h +++ b/shell/platform/darwin/ios/ios_surface_gl.h @@ -51,7 +51,7 @@ class IOSSurfaceGL : public IOSSurface, flow::ExternalViewEmbedder* GetExternalViewEmbedder() override; // |flow::ExternalViewEmbedder| - void SetFrameSize(SkISize frame_size) override; + void BeginFrame(SkISize frame_size) override; // |flow::ExternalViewEmbedder| void PrerollCompositeEmbeddedView(int view_id) override; diff --git a/shell/platform/darwin/ios/ios_surface_gl.mm b/shell/platform/darwin/ios/ios_surface_gl.mm index 236b05dacae05..cd0bb093d87d4 100644 --- a/shell/platform/darwin/ios/ios_surface_gl.mm +++ b/shell/platform/darwin/ios/ios_surface_gl.mm @@ -82,10 +82,11 @@ } } -void IOSSurfaceGL::SetFrameSize(SkISize frame_size) { +void IOSSurfaceGL::BeginFrame(SkISize frame_size) { FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); FML_CHECK(platform_views_controller != nullptr); platform_views_controller->SetFrameSize(frame_size); + [CATransaction begin]; } void IOSSurfaceGL::PrerollCompositeEmbeddedView(int view_id) { @@ -111,7 +112,10 @@ if (platform_views_controller == nullptr) { return true; } - return platform_views_controller->SubmitFrame(true, std::move(context), context_); + + bool submitted = platform_views_controller->SubmitFrame(true, std::move(context), context_); + [CATransaction commit]; + return submitted; } } // namespace shell diff --git a/shell/platform/darwin/ios/ios_surface_software.h b/shell/platform/darwin/ios/ios_surface_software.h index 1642497f27dfd..5106bdfb0aa3e 100644 --- a/shell/platform/darwin/ios/ios_surface_software.h +++ b/shell/platform/darwin/ios/ios_surface_software.h @@ -46,7 +46,7 @@ class IOSSurfaceSoftware final : public IOSSurface, flow::ExternalViewEmbedder* GetExternalViewEmbedder() override; // |flow::ExternalViewEmbedder| - void SetFrameSize(SkISize frame_size) override; + void BeginFrame(SkISize frame_size) override; // |flow::ExternalViewEmbedder| void PrerollCompositeEmbeddedView(int view_id) override; diff --git a/shell/platform/darwin/ios/ios_surface_software.mm b/shell/platform/darwin/ios/ios_surface_software.mm index a1017439c0057..5d120ef47c061 100644 --- a/shell/platform/darwin/ios/ios_surface_software.mm +++ b/shell/platform/darwin/ios/ios_surface_software.mm @@ -134,7 +134,7 @@ } } -void IOSSurfaceSoftware::SetFrameSize(SkISize frame_size) { +void IOSSurfaceSoftware::BeginFrame(SkISize frame_size) { FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); FML_CHECK(platform_views_controller != nullptr); platform_views_controller->SetFrameSize(frame_size);