Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 5229abd

Browse files
author
Chris Yang
committed
Do not involve external_view_embedder in submit frame process if threads are not merged.
1 parent ce0a30c commit 5229abd

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

shell/common/rasterizer.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ void Rasterizer::Draw(fml::RefPtr<Pipeline<flutter::LayerTree>> pipeline,
190190
consume_result = PipelineConsumeResult::MoreAvailable;
191191
}
192192

193-
// Merging the thread as we know the next `Draw` should be run on the platform
194-
// thread.
193+
// EndFrame should perform cleanups for the external_view_embedder.
195194
if (surface_ != nullptr && surface_->GetExternalViewEmbedder() != nullptr) {
196195
surface_->GetExternalViewEmbedder()->EndFrame(should_resubmit_frame,
197196
raster_thread_merger_);
@@ -469,7 +468,8 @@ RasterStatus Rasterizer::DrawToSurface(flutter::LayerTree& layer_tree) {
469468
raster_status == RasterStatus::kSkipAndRetry) {
470469
return raster_status;
471470
}
472-
if (external_view_embedder != nullptr) {
471+
if (external_view_embedder != nullptr &&
472+
(!raster_thread_merger_ || raster_thread_merger_->IsMerged())) {
473473
FML_DCHECK(!frame->IsSubmitted());
474474
external_view_embedder->SubmitFrame(surface_->GetContext(),
475475
std::move(frame));

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -469,12 +469,8 @@
469469
bool FlutterPlatformViewsController::SubmitFrame(GrDirectContext* gr_context,
470470
std::shared_ptr<IOSContext> ios_context,
471471
std::unique_ptr<SurfaceFrame> frame) {
472-
FML_DCHECK(flutter_view_);
473-
474472
// Any UIKit related code has to run on main thread.
475-
// When on a non-main thread, we only allow the rest of the method to run if there is no
476-
// Pending UIView operations.
477-
FML_DCHECK([[NSThread currentThread] isMainThread] || !HasPlatformViewThisOrNextFrame());
473+
FML_DCHECK(flutter_view_ && [[NSThread currentThread] isMainThread]);
478474

479475
DisposeViews();
480476

@@ -558,8 +554,6 @@
558554
BringLayersIntoView(platform_view_layers);
559555
// Mark all layers as available, so they can be used in the next frame.
560556
layer_pool_->RecycleLayers();
561-
// Reset the composition order, so next frame starts empty.
562-
composition_order_.clear();
563557

564558
did_submit &= frame->Submit();
565559

@@ -599,7 +593,10 @@
599593

600594
void FlutterPlatformViewsController::EndFrame(
601595
bool should_resubmit_frame,
602-
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) {}
596+
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) {
597+
// Reset the composition order, so next frame starts empty.
598+
composition_order_.clear();
599+
}
603600

604601
std::shared_ptr<FlutterPlatformViewLayer> FlutterPlatformViewsController::GetLayer(
605602
GrDirectContext* gr_context,

0 commit comments

Comments
 (0)