-
Notifications
You must be signed in to change notification settings - Fork 6k
PlatformView to set the correct overlay view frame, merge thread at the endFrame #33262
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -277,7 +277,6 @@ | |
| // Eventually, the frame is submitted once this method returns `kSuccess`. | ||
| // At that point, the raster tasks are handled on the platform thread. | ||
| CancelFrame(); | ||
| raster_thread_merger->MergeWithLease(kDefaultMergedLeaseDuration); | ||
| return PostPrerollResult::kSkipAndRetryFrame; | ||
| } | ||
| // If the post preroll action is successful, we will display platform views in the current frame. | ||
|
|
@@ -289,6 +288,14 @@ | |
| return PostPrerollResult::kSuccess; | ||
| } | ||
|
|
||
| void FlutterPlatformViewsController::EndFrame( | ||
| bool should_resubmit_frame, | ||
| fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) { | ||
| if (should_resubmit_frame) { | ||
| raster_thread_merger->MergeWithLease(kDefaultMergedLeaseDuration); | ||
| } | ||
| } | ||
|
|
||
| void FlutterPlatformViewsController::PrerollCompositeEmbeddedView( | ||
| int view_id, | ||
| std::unique_ptr<EmbeddedViewParams> params) { | ||
|
|
@@ -609,14 +616,18 @@ | |
| // This wrapper view masks the overlay view. | ||
| overlay_view_wrapper.frame = CGRectMake(rect.x() / screenScale, rect.y() / screenScale, | ||
| rect.width() / screenScale, rect.height() / screenScale); | ||
| // Set a unique view identifier, so the overlay wrapper can be identified in unit tests. | ||
| // Set a unique view identifier, so the overlay_view_wrapper can be identified in XCUITests. | ||
| overlay_view_wrapper.accessibilityIdentifier = | ||
| [NSString stringWithFormat:@"platform_view[%lld].overlay[%lld]", view_id, overlay_id]; | ||
|
|
||
| UIView* overlay_view = layer->overlay_view.get(); | ||
| // Set the size of the overlay view. | ||
| // This size is equal to the device screen size. | ||
| overlay_view.frame = flutter_view_.get().bounds; | ||
| overlay_view.frame = [flutter_view_.get() convertRect:flutter_view_.get().bounds | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. have you seen any side effects when the frame size is changed in every frame? Try running https://github.com/flutter/flutter/tree/195a1cc413bde5f7c1d194204608c4bc20659124/dev/benchmarks/platform_views_layout with this change. That test has an animated container that should cause this value to change after each frame https://github.com/flutter/flutter/blob/195a1cc413bde5f7c1d194204608c4bc20659124/dev/benchmarks/platform_views_layout/lib/main.dart#L121
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. I ran the benchmarks, there doesn't seem to be significant difference: With my change: master: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did you see any issue in general? if you run the app, and play with it? e.g. Could this change introduce jank or glitches?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, I didn't see this change introduce new janks or glitches.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. friendly ping @blasten There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no more suggestions. Thanks for looking! |
||
| toView:overlay_view_wrapper]; | ||
| // Set a unique view identifier, so the overlay_view can be identified in XCUITests. | ||
| overlay_view.accessibilityIdentifier = | ||
| [NSString stringWithFormat:@"platform_view[%lld].overlay_view[%lld]", view_id, overlay_id]; | ||
|
|
||
| std::unique_ptr<SurfaceFrame> frame = layer->surface->AcquireFrame(frame_size_); | ||
| // If frame is null, AcquireFrame already printed out an error message. | ||
|
|
@@ -625,9 +636,6 @@ | |
| } | ||
| SkCanvas* overlay_canvas = frame->SkiaCanvas(); | ||
| overlay_canvas->clear(SK_ColorTRANSPARENT); | ||
| // Offset the picture since its absolute position on the scene is determined | ||
| // by the position of the overlay view. | ||
| overlay_canvas->translate(-rect.x(), -rect.y()); | ||
| overlay_canvas->drawPicture(picture); | ||
|
|
||
| layer->did_submit_last_frame = frame->Submit(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,7 +84,7 @@ | |
| void IOSExternalViewEmbedder::EndFrame(bool should_resubmit_frame, | ||
| fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) { | ||
| TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::EndFrame"); | ||
| FML_CHECK(platform_views_controller_); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this deleted?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a CHECK, so it is essentially crashing the app if I think this check shouldn't be here at all.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's better to fail with a reasonable error message than null pointer dereferencing, right? Is there a situation in which
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there's any reason it would happen in the current code, but it might happen if rasterizer's logic changes. Good point to have a failing message, I will add the check back and add a failing message.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought about it but not sure what additional message to add that would be useful. We assume I could add something like "platform_views_controller_ must not be null" but it is redundant as crashing at
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. friendly ping @iskakaushik |
||
| platform_views_controller_->EndFrame(should_resubmit_frame, raster_thread_merger); | ||
| } | ||
|
|
||
| // |ExternalViewEmbedder| | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is moved to
EndFrameto ensure the threads are merged at the very end of the frame.