-
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
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
cae8d76 to
63ed36f
Compare
|
@zanderso Here's the fix for the PlatformView flickering issue. How do mark this to be a CP candidate? |
|
This will be easier to approve for a cherry-pick if it can have a test. |
I'm adding tests now. Building the test locally took some time and I just put the PR up before it :) |
|
@iskakaushik Do you mind take a look at code for both update? |
| // 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 comment
The 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
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.
Good point. I ran the benchmarks, there doesn't seem to be significant difference:
With my change:
"average_frame_build_time_millis": 0.2156956521739131,
"90th_percentile_frame_build_time_millis": 0.27,
"99th_percentile_frame_build_time_millis": 0.316,
"worst_frame_build_time_millis": 0.326,
"missed_frame_build_budget_count": 0,
"average_frame_rasterizer_time_millis": 4.833215053763439,
"90th_percentile_frame_rasterizer_time_millis": 6.668,
"99th_percentile_frame_rasterizer_time_millis": 7.84,
"worst_frame_rasterizer_time_millis": 9.612,
"missed_frame_rasterizer_budget_count": 0,
master:
"average_frame_build_time_millis": 0.21664516129032269,
"90th_percentile_frame_build_time_millis": 0.286,
"99th_percentile_frame_build_time_millis": 0.305,
"worst_frame_build_time_millis": 0.357,
"missed_frame_build_budget_count": 0,
"average_frame_rasterizer_time_millis": 4.918989130434783,
"90th_percentile_frame_rasterizer_time_millis": 6.905,
"99th_percentile_frame_rasterizer_time_millis": 8.33,
"worst_frame_rasterizer_time_millis": 9.434,
"missed_frame_rasterizer_budget_count": 0,
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.
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?
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.
no, I didn't see this change introduce new janks or glitches.
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.
friendly ping @blasten
Did you have other suggestions/comments?
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.
no more suggestions. Thanks for looking!
|
@zanderso Looks like the original issue on the app was magically fixed and the issue was closed. Since it is not a regression and requires a specific device/steps to reproduce, I would suggest to not cherry-pick. WDTY? |
|
I'm not sure that I trust that it was magically fixed. Is there a version of the app where it repros locally for you without your fix? |
draft test code format revert revert testing code cleanup clea nup revert scenario test for overlay view frame test thread merge at end frame add scenario tests fix typo
56eb0de to
eb94a6b
Compare
I wasn't able to repro the same exact issue they were experiencing. Not with local build, flutter stable/master, nor the TestFlight build. Mine looks a little bit different as shown in flutter/flutter#103076 and it repros even in stable. Their video capture, however, does look like some sort of syncing issue between PlatformView and Overlay. Since the fix on the thread merging in this PR fixed the flickering issue that I was experiencing (caused by frames not synchronized during thread merging), I guess the same code might fix the issue they saw. I asked them to test their app with this PR and see if it fixes the glitch that they saw. but it seem they couldn't reproduce the issue anymore. |
|
Got it. Not sure I completely follow the timeline, but if the issue was possibly introduced by the 120Hz change, then we should queue this up for a cherry-pick. Otherwise, that is if it's just a fix for a pre-existing issue, then I don't think we need a cherry-pick. |
|
This wasn't introduced by the 120hz work, rendering at high frame rates only made a previously present issue more apparent. I was able to reproduce this with the 120hz change reverted as well. |
Yes, the issue was not related to 120Hz. The issue happens randomly, I think it is a little more reproducible with 120hz enabled just because we draw more frames with 120Hz. |
|
Also note that the issue only happens on iPhone 13pro. I'm not sure why, but It is possible that Skia drawing outside of the canvas worked in previous iPhones but not the iPhone 13pro. |
|
Chatted with folks offline. It sounds like a cherry-pick isn't needed. Is this ready to land, though? |
|
friendly ping @iskakaushik for review |
| void IOSExternalViewEmbedder::EndFrame(bool should_resubmit_frame, | ||
| fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) { | ||
| TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::EndFrame"); | ||
| FML_CHECK(platform_views_controller_); |
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 deleted?
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 a CHECK, so it is essentially crashing the app if platform_views_controller_ is null, which is exactly what the next will do.
I think this check shouldn't be here at all.
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.
it's better to fail with a reasonable error message than null pointer dereferencing, right?
Is there a situation in which platform_views_controller_ can become null? Or do we check during initialization?
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.
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.
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.
I thought about it but not sure what additional message to add that would be useful. We assume platform_views_controller_ is not null here and it crashes if it is null.
I could add something like "platform_views_controller_ must not be null" but it is redundant as crashing at latform_views_controller_->EndFrame(should_resubmit_frame, raster_thread_merger); would self-explained it.
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.
friendly ping @iskakaushik
| // 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); |
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 EndFrame to ensure the threads are merged at the very end of the frame.
iskakaushik
left a comment
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.
LGTM
|
@cyanglaz is this ready to merge? |
blasten
left a comment
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.
LGTM
…ead at the endFrame (flutter/engine#33262)
This somehow fixes the flickering issue in flutter/flutter#103076, I'm not sure the exact reason behind it but it seems like it is related to Skia trying to draw off canvas.
This fixes some occasional unsynchronized frame, also observed in flutter/flutter#103076
I have observed another thread synchronization issue during thread un-merging. It seems a little more complicated so I'll create a separate PR for it .
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.