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 all 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
5 changes: 5 additions & 0 deletions shell/gpu/gpu_surface_metal.mm
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@

ReleaseUnusedDrawableIfNecessary();

// When there are platform views in the scene, the drawable needs to be presented in the same
// transaction as the one created for platform views. When the drawable are being presented from
// the raster thread, there is no such transaction.
layer_.get().presentsWithTransaction = [[NSThread currentThread] isMainThread];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, I would do the same thing in gpu_surace_gl but that does not have access to the layer as it is platform agnostic. The right fix for this is to add a method to the surface delegate that sets the layer property on iOS.


auto surface = SkSurface::MakeFromCAMetalLayer(context_.get(), // context
layer_.get(), // layer
kTopLeft_GrSurfaceOrigin, // origin
Expand Down
20 changes: 2 additions & 18 deletions shell/platform/darwin/ios/ios_surface.mm
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,15 @@ bool IsIosEmbeddedViewsPreviewEnabled() {
platform_views_controller_->CancelFrame();
// Committing the current transaction as |BeginFrame| will create a nested
// CATransaction otherwise.
if ([[NSThread currentThread] isMainThread]) {
// The only time we need to commit the `CATranscation` is when
// there are platform views in the scene, which has to be run on the
// main thread.
[CATransaction commit];
}
[CATransaction commit];
}

// |ExternalViewEmbedder|
void IOSSurface::BeginFrame(SkISize frame_size, GrContext* context, double device_pixel_ratio) {
TRACE_EVENT0("flutter", "IOSSurface::BeginFrame");
FML_CHECK(platform_views_controller_ != nullptr);
platform_views_controller_->SetFrameSize(frame_size);
if ([[NSThread currentThread] isMainThread]) {
// The only time we need to commit the `CATranscation` is when
// there are platform views in the scene, which has to be run on the
// main thread.
[CATransaction begin];
}
[CATransaction begin];
}

// |ExternalViewEmbedder|
Expand Down Expand Up @@ -160,12 +150,6 @@ bool IsIosEmbeddedViewsPreviewEnabled() {
// |ExternalViewEmbedder|
void IOSSurface::FinishFrame() {
TRACE_EVENT0("flutter", "IOSSurface::DidSubmitFrame");
if (![[NSThread currentThread] isMainThread]) {
return;
}
// The only time we need to commit the `CATranscation` is when
// there are platform views in the scene, which has to be run on the
// main thread.
[CATransaction commit];
}
} // namespace flutter