Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@
CancelFrame();
return PostPrerollResult::kSkipAndRetryFrame;
}
// If the post preroll action is successful, we will display platform views in the current frame.
// In order to sync the rendering of the platform views (quartz) with skia's rendering,
// We need to begin an explicit CATransaction. This transaction needs to be submitted
// after the current frame is submitted.
FML_DCHECK([[NSThread currentThread] isMainThread]);
[CATransaction begin];
catransaction_added_ = true;
raster_thread_merger->ExtendLeaseTo(kDefaultMergedLeaseDuration);
return PostPrerollResult::kSuccess;
}
Expand Down Expand Up @@ -548,6 +555,14 @@

did_submit &= frame->Submit();

// The frame is submitted with embedded platform views.
// There should be a |[CATransaction begin]| call in this frame prior to all the drawing.
// Now we need to commit the transaction.
if (catransaction_added_) {
FML_DCHECK([[NSThread currentThread] isMainThread]);
[CATransaction commit];
catransaction_added_ = false;
}
return did_submit;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ class FlutterPlatformViewsController {

std::unique_ptr<fml::WeakPtrFactory<FlutterPlatformViewsController>> weak_factory_;

bool catransaction_added_ = false;

void OnCreate(FlutterMethodCall* call, FlutterResult& result);
void OnDispose(FlutterMethodCall* call, FlutterResult& result);
void OnAcceptGesture(FlutterMethodCall* call, FlutterResult& result);
Expand Down
17 changes: 2 additions & 15 deletions shell/platform/darwin/ios/ios_surface.mm
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@
TRACE_EVENT0("flutter", "IOSSurface::CancelFrame");
FML_CHECK(platform_views_controller_ != nullptr);
platform_views_controller_->CancelFrame();
// Committing the current transaction as |BeginFrame| will create a nested
// CATransaction otherwise.
[CATransaction commit];
}

// |ExternalViewEmbedder|
Expand All @@ -84,7 +81,6 @@
TRACE_EVENT0("flutter", "IOSSurface::BeginFrame");
FML_CHECK(platform_views_controller_ != nullptr);
platform_views_controller_->SetFrameSize(frame_size);
[CATransaction begin];
}

// |ExternalViewEmbedder|
Expand All @@ -102,10 +98,6 @@
TRACE_EVENT0("flutter", "IOSSurface::PostPrerollAction");
FML_CHECK(platform_views_controller_ != nullptr);
PostPrerollResult result = platform_views_controller_->PostPrerollAction(raster_thread_merger);
if (result == PostPrerollResult::kSkipAndRetryFrame) {
// Commit the current transaction if the frame is dropped.
[CATransaction commit];
}
return result;
}

Expand All @@ -126,13 +118,8 @@
void IOSSurface::SubmitFrame(GrDirectContext* context, std::unique_ptr<SurfaceFrame> frame) {
TRACE_EVENT0("flutter", "IOSSurface::SubmitFrame");
FML_CHECK(platform_views_controller_ != nullptr);
bool submitted =
platform_views_controller_->SubmitFrame(std::move(context), ios_context_, std::move(frame));

if (submitted) {
TRACE_EVENT0("flutter", "IOSSurface::DidSubmitFrame");
[CATransaction commit];
}
platform_views_controller_->SubmitFrame(std::move(context), ios_context_, std::move(frame));
TRACE_EVENT0("flutter", "IOSSurface::DidSubmitFrame");
}

// |ExternalViewEmbedder|
Expand Down