From 74472ce6daa89097ea0644ffc87dfebfc9aaeb14 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Fri, 6 Nov 2020 15:26:47 -0800 Subject: [PATCH] Revert "Rasterizer is initialized with an external view embedder (#22348)" (#22367) This reverts commit 0d5f2e901d1953d04eb45004666d34a4537a0060. Due to merge conflicts, this also reverts #22275: Revert "Do not involve external_view_embedder in submit frame process if threads are not merged. (#22275)" This reverts commit 016fbde1bb275288242e2cf097b52af1dd66ab06. --- shell/common/platform_view.h | 4 +- shell/common/rasterizer.cc | 47 +++--- shell/common/rasterizer.h | 12 -- shell/common/rasterizer_unittests.cc | 152 ++---------------- shell/common/shell.cc | 4 - shell/common/shell_unittests.cc | 63 ++------ .../framework/Source/FlutterPlatformViews.mm | 25 ++- .../Source/FlutterPlatformViewsTest.mm | 62 ------- 8 files changed, 64 insertions(+), 305 deletions(-) diff --git a/shell/common/platform_view.h b/shell/common/platform_view.h index 6e12917b1849b..a67b4b793cce1 100644 --- a/shell/common/platform_view.h +++ b/shell/common/platform_view.h @@ -582,8 +582,6 @@ class PlatformView { ComputePlatformResolvedLocales( const std::vector& supported_locale_data); - virtual std::shared_ptr CreateExternalViewEmbedder(); - protected: PlatformView::Delegate& delegate_; const TaskRunners task_runners_; @@ -596,6 +594,8 @@ class PlatformView { // GPU task runner. virtual std::unique_ptr CreateRenderingSurface(); + virtual std::shared_ptr CreateExternalViewEmbedder(); + private: FML_DISALLOW_COPY_AND_ASSIGN(PlatformView); }; diff --git a/shell/common/rasterizer.cc b/shell/common/rasterizer.cc index eb81265daf48d..6679943bb2b2d 100644 --- a/shell/common/rasterizer.cc +++ b/shell/common/rasterizer.cc @@ -76,8 +76,8 @@ void Rasterizer::Setup(std::unique_ptr surface) { user_override_resource_cache_bytes_); } compositor_context_->OnGrContextCreated(); - if (external_view_embedder_ && - external_view_embedder_->SupportsDynamicThreadMerging() && + if (surface_->GetExternalViewEmbedder() && + surface_->GetExternalViewEmbedder()->SupportsDynamicThreadMerging() && !raster_thread_merger_) { const auto platform_id = delegate_.GetTaskRunners().GetPlatformTaskRunner()->GetTaskQueueId(); @@ -190,10 +190,11 @@ void Rasterizer::Draw(fml::RefPtr> pipeline, consume_result = PipelineConsumeResult::MoreAvailable; } - // EndFrame should perform cleanups for the external_view_embedder. - if (external_view_embedder_) { - external_view_embedder_->EndFrame(should_resubmit_frame, - raster_thread_merger_); + // Merging the thread as we know the next `Draw` should be run on the platform + // thread. + if (surface_ != nullptr && surface_->GetExternalViewEmbedder() != nullptr) { + surface_->GetExternalViewEmbedder()->EndFrame(should_resubmit_frame, + raster_thread_merger_); } // Consume as many pipeline items as possible. But yield the event loop @@ -423,12 +424,14 @@ RasterStatus Rasterizer::DrawToSurface(flutter::LayerTree& layer_tree) { // for instrumentation. compositor_context_->ui_time().SetLapTime(layer_tree.build_time()); + auto* external_view_embedder = surface_->GetExternalViewEmbedder(); + SkCanvas* embedder_root_canvas = nullptr; - if (external_view_embedder_) { - external_view_embedder_->BeginFrame( + if (external_view_embedder != nullptr) { + external_view_embedder->BeginFrame( layer_tree.frame_size(), surface_->GetContext(), layer_tree.device_pixel_ratio(), raster_thread_merger_); - embedder_root_canvas = external_view_embedder_->GetRootCanvas(); + embedder_root_canvas = external_view_embedder->GetRootCanvas(); } // On Android, the external view embedder deletes surfaces in `BeginFrame`. @@ -451,13 +454,13 @@ RasterStatus Rasterizer::DrawToSurface(flutter::LayerTree& layer_tree) { embedder_root_canvas ? embedder_root_canvas : frame->SkiaCanvas(); auto compositor_frame = compositor_context_->AcquireFrame( - surface_->GetContext(), // skia GrContext - root_surface_canvas, // root surface canvas - external_view_embedder_.get(), // external view embedder - root_surface_transformation, // root surface transformation - true, // instrumentation enabled - frame->supports_readback(), // surface supports pixel reads - raster_thread_merger_ // thread merger + surface_->GetContext(), // skia GrContext + root_surface_canvas, // root surface canvas + external_view_embedder, // external view embedder + root_surface_transformation, // root surface transformation + true, // instrumentation enabled + frame->supports_readback(), // surface supports pixel reads + raster_thread_merger_ // thread merger ); if (compositor_frame) { @@ -466,11 +469,10 @@ RasterStatus Rasterizer::DrawToSurface(flutter::LayerTree& layer_tree) { raster_status == RasterStatus::kSkipAndRetry) { return raster_status; } - if (external_view_embedder_ != nullptr && - (!raster_thread_merger_ || raster_thread_merger_->IsMerged())) { + if (external_view_embedder != nullptr) { FML_DCHECK(!frame->IsSubmitted()); - external_view_embedder_->SubmitFrame(surface_->GetContext(), - std::move(frame)); + external_view_embedder->SubmitFrame(surface_->GetContext(), + std::move(frame)); } else { frame->Submit(); } @@ -651,11 +653,6 @@ void Rasterizer::SetNextFrameCallback(const fml::closure& callback) { next_frame_callback_ = callback; } -void Rasterizer::SetExternalViewEmbedder( - const std::shared_ptr& view_embedder) { - external_view_embedder_ = view_embedder; -} - void Rasterizer::FireNextFrameCallbackIfPresent() { if (!next_frame_callback_) { return; diff --git a/shell/common/rasterizer.h b/shell/common/rasterizer.h index 0637ad37ca955..b658f18e0674c 100644 --- a/shell/common/rasterizer.h +++ b/shell/common/rasterizer.h @@ -8,7 +8,6 @@ #include #include -#include "flow/embedded_views.h" #include "flutter/common/settings.h" #include "flutter/common/task_runners.h" #include "flutter/flow/compositor_context.h" @@ -350,16 +349,6 @@ class Rasterizer final : public SnapshotDelegate { /// void SetNextFrameCallback(const fml::closure& callback); - //---------------------------------------------------------------------------- - /// @brief Set the External View Embedder. This is done on shell - /// initialization. This is non-null on platforms that support - /// embedding externally composited views. - /// - /// @param[in] view_embedder The external view embedder object. - /// - void SetExternalViewEmbedder( - const std::shared_ptr& view_embedder); - //---------------------------------------------------------------------------- /// @brief Returns a pointer to the compositor context used by this /// rasterizer. This pointer will never be `nullptr`. @@ -448,7 +437,6 @@ class Rasterizer final : public SnapshotDelegate { std::optional max_cache_bytes_; fml::RefPtr raster_thread_merger_; fml::TaskRunnerAffineWeakPtrFactory weak_factory_; - std::shared_ptr external_view_embedder_; // |SnapshotDelegate| sk_sp MakeRasterSnapshot(sk_sp picture, diff --git a/shell/common/rasterizer_unittests.cc b/shell/common/rasterizer_unittests.cc index 8ce71e2682975..47a1f700fc843 100644 --- a/shell/common/rasterizer_unittests.cc +++ b/shell/common/rasterizer_unittests.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#define FML_USED_ON_EMBEDDER - #include "flutter/shell/common/rasterizer.h" #include "flutter/shell/common/thread_host.h" @@ -11,7 +9,6 @@ #include "gmock/gmock.h" using testing::_; -using testing::ByMove; using testing::Return; using testing::ReturnRef; @@ -95,65 +92,7 @@ TEST(RasterizerTest, drawEmptyPipeline) { latch.Wait(); } -TEST(RasterizerTest, - drawWithExternalViewEmbedder_ExternalViewEmbedderSubmitFrameCalled) { - std::string test_name = - ::testing::UnitTest::GetInstance()->current_test_info()->name(); - ThreadHost thread_host("io.flutter.test." + test_name + ".", - ThreadHost::Type::Platform | ThreadHost::Type::GPU | - ThreadHost::Type::IO | ThreadHost::Type::UI); - TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(), - thread_host.raster_thread->GetTaskRunner(), - thread_host.ui_thread->GetTaskRunner(), - thread_host.io_thread->GetTaskRunner()); - MockDelegate delegate; - EXPECT_CALL(delegate, GetTaskRunners()) - .WillRepeatedly(ReturnRef(task_runners)); - EXPECT_CALL(delegate, OnFrameRasterized(_)); - auto rasterizer = std::make_unique(delegate); - auto surface = std::make_unique(); - std::shared_ptr external_view_embedder = - std::make_shared(); - rasterizer->SetExternalViewEmbedder(external_view_embedder); - - auto surface_frame = std::make_unique( - /*surface=*/nullptr, /*supports_readback=*/true, - /*submit_callback=*/[](const SurfaceFrame&, SkCanvas*) { return true; }); - EXPECT_CALL(*surface, AcquireFrame(SkISize())) - .WillOnce(Return(ByMove(std::move(surface_frame)))); - - EXPECT_CALL(*external_view_embedder, - BeginFrame(/*frame_size=*/SkISize(), /*context=*/nullptr, - /*device_pixel_ratio=*/2.0, - /*raster_thread_merger=*/ - fml::RefPtr(nullptr))) - .Times(1); - EXPECT_CALL(*external_view_embedder, SubmitFrame).Times(1); - EXPECT_CALL( - *external_view_embedder, - EndFrame(/*should_resubmit_frame=*/false, - /*raster_thread_merger=*/fml::RefPtr( - nullptr))) - .Times(1); - - rasterizer->Setup(std::move(surface)); - fml::AutoResetWaitableEvent latch; - thread_host.raster_thread->GetTaskRunner()->PostTask([&] { - auto pipeline = fml::AdoptRef(new Pipeline(/*depth=*/10)); - auto layer_tree = std::make_unique(/*frame_size=*/SkISize(), - /*device_pixel_ratio=*/2.0f); - bool result = pipeline->Produce().Complete(std::move(layer_tree)); - EXPECT_TRUE(result); - auto no_discard = [](LayerTree&) { return false; }; - rasterizer->Draw(pipeline, no_discard); - latch.Signal(); - }); - latch.Wait(); -} - -TEST( - RasterizerTest, - drawWithExternalViewEmbedderAndThreadMergerNotMerged_ExternalViewEmbedderSubmitFrameNotCalled) { +TEST(RasterizerTest, drawWithExternalViewEmbedder) { std::string test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name(); ThreadHost thread_host("io.flutter.test." + test_name + ".", @@ -169,27 +108,14 @@ TEST( EXPECT_CALL(delegate, OnFrameRasterized(_)); auto rasterizer = std::make_unique(delegate); auto surface = std::make_unique(); - std::shared_ptr external_view_embedder = - std::make_shared(); - rasterizer->SetExternalViewEmbedder(external_view_embedder); - EXPECT_CALL(*external_view_embedder, SupportsDynamicThreadMerging) - .WillRepeatedly(Return(true)); - auto surface_frame = std::make_unique( - /*surface=*/nullptr, /*supports_readback=*/true, - /*submit_callback=*/[](const SurfaceFrame&, SkCanvas*) { return true; }); - EXPECT_CALL(*surface, AcquireFrame(SkISize())) - .WillOnce(Return(ByMove(std::move(surface_frame)))); - - EXPECT_CALL(*external_view_embedder, - BeginFrame(/*frame_size=*/SkISize(), /*context=*/nullptr, - /*device_pixel_ratio=*/2.0, - /*raster_thread_merger=*/_)) - .Times(1); - EXPECT_CALL(*external_view_embedder, SubmitFrame).Times(0); - EXPECT_CALL(*external_view_embedder, EndFrame(/*should_resubmit_frame=*/false, - /*raster_thread_merger=*/_)) - .Times(1); - + MockExternalViewEmbedder external_view_embedder; + EXPECT_CALL(*surface, GetExternalViewEmbedder()) + .WillRepeatedly(Return(&external_view_embedder)); + EXPECT_CALL(external_view_embedder, + BeginFrame(SkISize(), nullptr, 2.0, + fml::RefPtr(nullptr))); + EXPECT_CALL(external_view_embedder, + EndFrame(false, fml::RefPtr(nullptr))); rasterizer->Setup(std::move(surface)); fml::AutoResetWaitableEvent latch; thread_host.raster_thread->GetTaskRunner()->PostTask([&] { @@ -198,66 +124,12 @@ TEST( /*device_pixel_ratio=*/2.0f); bool result = pipeline->Produce().Complete(std::move(layer_tree)); EXPECT_TRUE(result); - auto no_discard = [](LayerTree&) { return false; }; + std::function no_discard = [](LayerTree&) { + return false; + }; rasterizer->Draw(pipeline, no_discard); latch.Signal(); }); latch.Wait(); } - -TEST( - RasterizerTest, - drawWithExternalViewEmbedderAndThreadsMerged_ExternalViewEmbedderSubmitFrameCalled) { - std::string test_name = - ::testing::UnitTest::GetInstance()->current_test_info()->name(); - ThreadHost thread_host("io.flutter.test." + test_name + ".", - ThreadHost::Type::Platform | ThreadHost::Type::GPU | - ThreadHost::Type::IO | ThreadHost::Type::UI); - fml::MessageLoop::EnsureInitializedForCurrentThread(); - TaskRunners task_runners("test", - fml::MessageLoop::GetCurrent().GetTaskRunner(), - fml::MessageLoop::GetCurrent().GetTaskRunner(), - thread_host.ui_thread->GetTaskRunner(), - thread_host.io_thread->GetTaskRunner()); - - MockDelegate delegate; - EXPECT_CALL(delegate, GetTaskRunners()) - .WillRepeatedly(ReturnRef(task_runners)); - EXPECT_CALL(delegate, OnFrameRasterized(_)); - - auto rasterizer = std::make_unique(delegate); - auto surface = std::make_unique(); - - std::shared_ptr external_view_embedder = - std::make_shared(); - rasterizer->SetExternalViewEmbedder(external_view_embedder); - - auto surface_frame = std::make_unique( - /*surface=*/nullptr, /*supports_readback=*/true, - /*submit_callback=*/[](const SurfaceFrame&, SkCanvas*) { return true; }); - EXPECT_CALL(*surface, AcquireFrame(SkISize())) - .WillOnce(Return(ByMove(std::move(surface_frame)))); - EXPECT_CALL(*external_view_embedder, SupportsDynamicThreadMerging) - .WillRepeatedly(Return(true)); - - EXPECT_CALL(*external_view_embedder, - BeginFrame(/*frame_size=*/SkISize(), /*context=*/nullptr, - /*device_pixel_ratio=*/2.0, - /*raster_thread_merger=*/_)) - .Times(1); - EXPECT_CALL(*external_view_embedder, SubmitFrame).Times(1); - EXPECT_CALL(*external_view_embedder, EndFrame(/*should_resubmit_frame=*/false, - /*raster_thread_merger=*/_)) - .Times(1); - - rasterizer->Setup(std::move(surface)); - - auto pipeline = fml::AdoptRef(new Pipeline(/*depth=*/10)); - auto layer_tree = std::make_unique(/*frame_size=*/SkISize(), - /*device_pixel_ratio=*/2.0f); - bool result = pipeline->Produce().Complete(std::move(layer_tree)); - EXPECT_TRUE(result); - auto no_discard = [](LayerTree&) { return false; }; - rasterizer->Draw(pipeline, no_discard); -} } // namespace flutter diff --git a/shell/common/shell.cc b/shell/common/shell.cc index 6fd7f83f26314..0f470cff37c6f 100644 --- a/shell/common/shell.cc +++ b/shell/common/shell.cc @@ -547,10 +547,6 @@ bool Shell::Setup(std::unique_ptr platform_view, rasterizer_ = std::move(rasterizer); io_manager_ = std::move(io_manager); - // Set the external view embedder for the rasterizer. - auto view_embedder = platform_view_->CreateExternalViewEmbedder(); - rasterizer_->SetExternalViewEmbedder(view_embedder); - // The weak ptr must be generated in the platform thread which owns the unique // ptr. weak_engine_ = engine_->GetWeakPtr(); diff --git a/shell/common/shell_unittests.cc b/shell/common/shell_unittests.cc index 604b344748f5d..7642d7c4f8534 100644 --- a/shell/common/shell_unittests.cc +++ b/shell/common/shell_unittests.cc @@ -1051,18 +1051,12 @@ TEST_F(ShellTest, auto settings = CreateSettingsForFixture(); fml::AutoResetWaitableEvent end_frame_latch; std::shared_ptr external_view_embedder; - fml::RefPtr raster_thread_merger_ref; + auto end_frame_callback = [&](bool should_resubmit_frame, fml::RefPtr raster_thread_merger) { - if (!raster_thread_merger_ref) { - raster_thread_merger_ref = raster_thread_merger; - } - if (should_resubmit_frame && !raster_thread_merger->IsMerged()) { - raster_thread_merger->MergeWithLease(10); - external_view_embedder->UpdatePostPrerollResult( - PostPrerollResult::kSuccess); - } + external_view_embedder->UpdatePostPrerollResult( + PostPrerollResult::kSuccess); end_frame_latch.Signal(); }; external_view_embedder = std::make_shared( @@ -1070,6 +1064,7 @@ TEST_F(ShellTest, auto shell = CreateShell(std::move(settings), GetTaskRunnersForFixture(), false, external_view_embedder); + PlatformViewNotifyCreated(shell.get()); auto configuration = RunConfiguration::InferFromSettings(settings); @@ -1079,18 +1074,13 @@ TEST_F(ShellTest, ASSERT_EQ(0, external_view_embedder->GetSubmittedFrameCount()); PumpOneFrame(shell.get()); - // `EndFrame` changed the post preroll result to `kSuccess` and merged the - // threads. During the frame, the threads are not merged, So no - // `external_view_embedder->GetSubmittedFrameCount()` is called. + // `EndFrame` changed the post preroll result to `kSuccess`. end_frame_latch.Wait(); - ASSERT_TRUE(raster_thread_merger_ref->IsMerged()); - ASSERT_EQ(0, external_view_embedder->GetSubmittedFrameCount()); + ASSERT_EQ(1, external_view_embedder->GetSubmittedFrameCount()); - // This is the resubmitted frame, which threads are also merged. end_frame_latch.Wait(); - ASSERT_EQ(1, external_view_embedder->GetSubmittedFrameCount()); + ASSERT_EQ(2, external_view_embedder->GetSubmittedFrameCount()); - PlatformViewNotifyDestroyed(shell.get()); DestroyShell(std::move(shell)); } @@ -2030,29 +2020,14 @@ TEST_F(ShellTest, DiscardLayerTreeOnResize) { SkISize expected_size = SkISize::Make(400, 200); fml::AutoResetWaitableEvent end_frame_latch; - std::shared_ptr external_view_embedder; - fml::RefPtr raster_thread_merger_ref; - auto end_frame_callback = - [&](bool should_merge_thread, - fml::RefPtr raster_thread_merger) { - if (!raster_thread_merger_ref) { - raster_thread_merger_ref = raster_thread_merger; - } - if (should_merge_thread) { - // TODO(cyanglaz): This test used external_view_embedder so we need to - // merge the threads here. However, the scenario it is testing is - // unrelated to platform views. We should consider to update this test - // so it doesn't require external_view_embedder. - // https://github.com/flutter/flutter/issues/69895 - raster_thread_merger->MergeWithLease(10); - external_view_embedder->UpdatePostPrerollResult( - PostPrerollResult::kSuccess); - } - end_frame_latch.Signal(); - }; - external_view_embedder = std::make_shared( - std::move(end_frame_callback), PostPrerollResult::kResubmitFrame, true); + auto end_frame_callback = [&](bool, fml::RefPtr) { + end_frame_latch.Signal(); + }; + + std::shared_ptr external_view_embedder = + std::make_shared( + std::move(end_frame_callback), PostPrerollResult::kSuccess, true); std::unique_ptr shell = CreateShell( settings, GetTaskRunnersForFixture(), false, external_view_embedder); @@ -2073,6 +2048,8 @@ TEST_F(ShellTest, DiscardLayerTreeOnResize) { RunEngine(shell.get(), std::move(configuration)); + fml::WeakPtr runtime_delegate = shell->GetEngine(); + PumpOneFrame(shell.get(), static_cast(wrong_size.width()), static_cast(wrong_size.height())); @@ -2080,22 +2057,14 @@ TEST_F(ShellTest, DiscardLayerTreeOnResize) { ASSERT_EQ(0, external_view_embedder->GetSubmittedFrameCount()); - // Threads will be merged at the end of this frame. PumpOneFrame(shell.get(), static_cast(expected_size.width()), static_cast(expected_size.height())); end_frame_latch.Wait(); - // Even the threads are merged at the end of the frame, - // during the frame, the threads are not merged, - // So no `external_view_embedder->GetSubmittedFrameCount()` is called. - ASSERT_TRUE(raster_thread_merger_ref->IsMerged()); - ASSERT_EQ(0, external_view_embedder->GetSubmittedFrameCount()); - end_frame_latch.Wait(); ASSERT_EQ(1, external_view_embedder->GetSubmittedFrameCount()); ASSERT_EQ(expected_size, external_view_embedder->GetLastSubmittedFrameSize()); - PlatformViewNotifyDestroyed(shell.get()); DestroyShell(std::move(shell)); } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index 16da52e578f9b..ef1860037eeb1 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -342,9 +342,6 @@ void FlutterPlatformViewsController::ApplyMutators(const MutatorsStack& mutators_stack, UIView* embedded_view) { - if (flutter_view_ == nullptr) { - return; - } FML_DCHECK(CATransform3DEqualToTransform(embedded_view.layer.transform, CATransform3DIdentity)); ResetAnchor(embedded_view.layer); ChildClippingView* clipView = (ChildClippingView*)embedded_view.superview; @@ -401,6 +398,7 @@ void FlutterPlatformViewsController::CompositeWithParams(int view_id, const EmbeddedViewParams& params) { + FML_DCHECK(flutter_view_); CGRect frame = CGRectMake(0, 0, params.sizePoints().width(), params.sizePoints().height()); UIView* touchInterceptor = touch_interceptors_[view_id].get(); touchInterceptor.layer.transform = CATransform3DIdentity; @@ -421,8 +419,9 @@ } SkCanvas* FlutterPlatformViewsController::CompositeEmbeddedView(int view_id) { - // Any UIKit related code has to run on main thread. - FML_DCHECK([[NSThread currentThread] isMainThread]); + FML_DCHECK(flutter_view_); + // TODO(amirh): assert that this is running on the platform thread once we support the iOS + // embedded views thread configuration. // Do nothing if the view doesn't need to be composited. if (views_to_recomposite_.count(view_id) == 0) { @@ -470,11 +469,12 @@ bool FlutterPlatformViewsController::SubmitFrame(GrDirectContext* gr_context, std::shared_ptr ios_context, std::unique_ptr frame) { + FML_DCHECK(flutter_view_); + // Any UIKit related code has to run on main thread. - FML_DCHECK([[NSThread currentThread] isMainThread]); - if (flutter_view_ == nullptr) { - return frame->Submit(); - } + // 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] || !HasPlatformViewThisOrNextFrame()); DisposeViews(); @@ -558,6 +558,8 @@ BringLayersIntoView(platform_view_layers); // Mark all layers as available, so they can be used in the next frame. layer_pool_->RecycleLayers(); + // Reset the composition order, so next frame starts empty. + composition_order_.clear(); did_submit &= frame->Submit(); @@ -597,10 +599,7 @@ void FlutterPlatformViewsController::EndFrame( bool should_resubmit_frame, - fml::RefPtr raster_thread_merger) { - // Reset the composition order, so next frame starts empty. - composition_order_.clear(); -} + fml::RefPtr raster_thread_merger) {} std::shared_ptr FlutterPlatformViewsController::GetLayer( GrDirectContext* gr_context, diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm index f93d88c95e880..b71b603bc379e 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm @@ -602,68 +602,6 @@ - (void)testSetFlutterViewControllerAfterCreateCanStillDispatchTouchEvents { flutterPlatformViewsController->Reset(); } -- (void)testFlutterPlatformViewControllerSubmitFrameWithoutFlutterViewNotCrashing { - flutter::FlutterPlatformViewsTestMockPlatformViewDelegate mock_delegate; - auto thread_task_runner = CreateNewThread("FlutterPlatformViewsTest"); - flutter::TaskRunners runners(/*label=*/self.name.UTF8String, - /*platform=*/thread_task_runner, - /*raster=*/thread_task_runner, - /*ui=*/thread_task_runner, - /*io=*/thread_task_runner); - auto surface_factory = flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware); - auto platform_view = std::make_unique( - /*delegate=*/mock_delegate, - /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - /*ios_surface_factory=*/surface_factory, - /*task_runners=*/runners); - - auto flutterPlatformViewsController = - std::make_shared(surface_factory); - surface_factory->SetPlatformViewsController(flutterPlatformViewsController); - - FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; - flutterPlatformViewsController->RegisterViewFactory( - factory, @"MockFlutterPlatformView", - FlutterPlatformViewGestureRecognizersBlockingPolicyEager); - FlutterResult result = ^(id result) { - }; - flutterPlatformViewsController->OnMethodCall( - [FlutterMethodCall - methodCallWithMethodName:@"create" - arguments:@{@"id" : @2, @"viewType" : @"MockFlutterPlatformView"}], - result); - - XCTAssertNotNil(gMockPlatformView); - - // Create embedded view params - flutter::MutatorsStack stack; - SkMatrix finalMatrix; - - auto embeddedViewParams_1 = - std::make_unique(finalMatrix, SkSize::Make(300, 300), stack); - - flutterPlatformViewsController->PrerollCompositeEmbeddedView(2, std::move(embeddedViewParams_1)); - flutterPlatformViewsController->CompositeEmbeddedView(2); - auto mock_surface = std::make_unique( - nullptr, true, - [](const flutter::SurfaceFrame& surface_frame, SkCanvas* canvas) { return false; }); - XCTAssertFalse( - flutterPlatformViewsController->SubmitFrame(nullptr, nullptr, std::move(mock_surface))); - - auto embeddedViewParams_2 = - std::make_unique(finalMatrix, SkSize::Make(300, 300), stack); - flutterPlatformViewsController->PrerollCompositeEmbeddedView(2, std::move(embeddedViewParams_2)); - flutterPlatformViewsController->CompositeEmbeddedView(2); - auto mock_surface_submit_false = std::make_unique( - nullptr, true, - [](const flutter::SurfaceFrame& surface_frame, SkCanvas* canvas) { return true; }); - XCTAssertTrue(flutterPlatformViewsController->SubmitFrame(nullptr, nullptr, - std::move(mock_surface_submit_false))); - - flutterPlatformViewsController->Reset(); -} - - (int)alphaOfPoint:(CGPoint)point onView:(UIView*)view { unsigned char pixel[4] = {0};