-
Notifications
You must be signed in to change notification settings - Fork 6k
share platform view slicing logic across iOS and Android. #54010
share platform view slicing logic across iOS and Android. #54010
Conversation
…ne into combine_slicing_logic
By Android strategy, do you mean having a global limit of overlay count? |
AFAIK there is no global limit on the number of overlays, but we create at most one overlay per embedder view slice. |
const std::unordered_map<int64_t, SkRect>& view_rects) { | ||
std::unordered_map<int64_t, SkRect> overlay_layers; | ||
|
||
auto current_frame_view_count = composition_order.size(); |
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.
just so that i understand - this count is the count of platform views right?
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.
Correct
// Limit the number of native views, so it doesn't grow forever. | ||
// | ||
// In this case, the rects are merged into a single one that is the union | ||
// of all the rects. |
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.
iOS used to have 2 overlays per platform view as the limit. Do you have any context why we picked 2?
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.
as far as I can tell it was aribtrarily chosen
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.
Wondering if there are any benefit of having multiple overlays despite of the performance overhead. Otherwise it's odd that we picked 2 before. @cbracken do you recall?
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.
its possible that at one point the overlay surfaces weren't screen sized, so shrinking the overlays as small as possible improved performance. overlay sizes aren;t stable however, which is what lead to using the frame size in all cases - which defeats the purpose of minimizing overlay size.
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.
Talked to @jonahwilliams about this this morning but no, I don't recall this splitting logic at all and it's surprising to me that we're doing it -- adding layers should harm performance if anything. Could be something like what Jonah is suggesting.
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.
the subpixel overlap issue
Do you mean this? flutter/flutter#143420
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.
Yup
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.
Gotcha. This PR should move the metrics on both iOS (by reducing the limit from 2 to 1) and Android (by fixing the 1 px overlay). Do you think I should make our ads benchmark work on Android (should be a quick change? CC @jmagman correct me if it's not), so that we can measure both?
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.
Almost all Android PVs will use TLHC by default, which does not use platform view slicing. There is work this year to make android PVs work more like iOS by default, but without any of the terrible downsides of the current approach.
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 means we don't need the Android benchmark to run for this PR (since it's not the implementation used in Android yet), but we may need it later down the road, right? (flutter/flutter#152200)
|
||
namespace flutter { | ||
|
||
/// @brief Compute the required overlay layers and clip the view slices |
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.
Can this documentation be elaborated? What are the integer handles? How are they created. What is the rect that is returned? The embedder view slice is also not documented so there are no breadcrumbs there either.
Can these go in a struct with a custom hasher and equality checker?
If this is just moving code around and you want to limit scope, then we could probably do it in a followup. Just that from the perspective of someone not super familiar with slicing, this reads a bit dense.
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.
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.
sgtm
ping @chinmaygarde @cbracken @hellohuanlin can you either approve or make suggestions? This patch is blocking very high priority work. |
Sorry for the delay. Will take another look today! |
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.
Ah, didn't realize you were blocked without pending following.
I'm not super comfortable with this code but gradually refactoring and documenting this code works for me. Looks fine to me and a lot of it is moving stuff to be shared. For this reason, happy to LGTM but please me know if I should focus on something specific.
@jonahwilliams let me quickly pull the code and check if the overlay merging logic still works on iOS. |
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.
Confirmed the overlay merging logic worked! Hopefully this can move our benchmark a bit
…152260) flutter/engine@490576d...c2f489d 2024-07-24 [email protected] Fix embedder comments about struct_size (flutter/engine#54077) 2024-07-24 [email protected] share platform view slicing logic across iOS and Android. (flutter/engine#54010) 2024-07-24 [email protected] [skwasm] Fix platform view occlusion logic. (flutter/engine#54061) 2024-07-24 [email protected] Roll Skia from 25f26f673502 to c11932925658 (4 revisions) (flutter/engine#54081) 2024-07-24 [email protected] Upgrade Engine Android SDK to 35 (flutter/engine#53574) 2024-07-24 [email protected] Roll Skia from a9b1043eb23e to 25f26f673502 (1 revision) (flutter/engine#54079) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…lutter#152260) flutter/engine@490576d...c2f489d 2024-07-24 [email protected] Fix embedder comments about struct_size (flutter/engine#54077) 2024-07-24 [email protected] share platform view slicing logic across iOS and Android. (flutter/engine#54010) 2024-07-24 [email protected] [skwasm] Fix platform view occlusion logic. (flutter/engine#54061) 2024-07-24 [email protected] Roll Skia from 25f26f673502 to c11932925658 (4 revisions) (flutter/engine#54081) 2024-07-24 [email protected] Upgrade Engine Android SDK to 35 (flutter/engine#53574) 2024-07-24 [email protected] Roll Skia from a9b1043eb23e to 25f26f673502 (1 revision) (flutter/engine#54079) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…lutter#152260) flutter/engine@490576d...c2f489d 2024-07-24 [email protected] Fix embedder comments about struct_size (flutter/engine#54077) 2024-07-24 [email protected] share platform view slicing logic across iOS and Android. (flutter/engine#54010) 2024-07-24 [email protected] [skwasm] Fix platform view occlusion logic. (flutter/engine#54061) 2024-07-24 [email protected] Roll Skia from 25f26f673502 to c11932925658 (4 revisions) (flutter/engine#54081) 2024-07-24 [email protected] Upgrade Engine Android SDK to 35 (flutter/engine#53574) 2024-07-24 [email protected] Roll Skia from a9b1043eb23e to 25f26f673502 (1 revision) (flutter/engine#54079) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
This removes support for "unobstructed platform views" on iOS - instead prefering to use the Android strategy of minimizing overlay layers, as this is generally more performant.