-
Notifications
You must be signed in to change notification settings - Fork 6k
Fix embedder mutation order #15566
Fix embedder mutation order #15566
Conversation
|
I'm going to tag @chinmaygarde as it looks like he originally authored this code, but I have to say that the original looks correct and the fix looks like it will have the wrong behavior. The mutators stack was constructed from the top of the tree with transforms pushed as the tree was descended. Thus, child transforms appear later in the vector compared to parent transforms. In that ordering, the device pixel ratio and root transform must be before the root of the entire tree. The way the code was originally written looks like this is happening as intended, so you get: root transform -> top-most transform layer transform -> some child transform -> some grandchild transform -> etc. With the proposed fix, it looks like the ordering will be: top-most transform layer transform -> some child transform -> some grandchild transform -> etc. -> root transform. I don't think that is right, but perhaps I am reading the history of how the mutators stack was constructed. |
|
Thanks for adding Chinmay, I couldn't add him myself. That's actually the issue. Based on the documentation of MutatorsStack[1], given a stack of transforms {T1, T2, T3} where T1 is the top and T3 is the bottom they need to be applied in T1(T2(T3(P))) order to the platform view layer (P). Now, if we add the root transform (RT) that would be applied after T1, not before T3, so RT(T1(T2(T3(P)))). Now, the for-loop in line 129 goes from bottom to top, so |mutations_array| will look like {T3, T2, T1} without RT. If the root transform is pushed at the top, |mutations_array| will look like {RT, T3, T2, T1} which is incorrect. I'll concede that I may have misunderstood the embedder.h[2] documentation and the reversal at line 168 isn't necessary, though it would still clash with the documentation: "... first mutation in the list will be a transformation mutation to make sure subsequent mutations are in the correct coordinate space". That essentially tells me that RT is at the top, so the list needs to be reversed. This also makes sense to me since the embedder gets the transformed platform view and would be applying the inverse transforms to get back to the platform view (P). [1] https://github.com/flutter/engine/blob/master/flow/embedded_views.h#L123 |
|
I think the problem is that Bottom() is implemented to point to the most recently pushed item, but typical stack terminology is that Bottom() is the first item to have been pushed and the last item that would be popped. You are correct that the root transform should be closest to the first item pushed and it looks like that is Top() based on the implementation of the MutatorsStack, but that seems backwards to me and why I thought that the original code was correct. Should the implementations of Bottom() and Top() be reversed? |
chinmaygarde
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.
I was confused with the terminology when this was initially written. I can correct this in another patch but this looks good to me and thanks for the test.
dnicoara
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.
I think the problem is that Bottom() is implemented to point to the most recently pushed item, but typical stack terminology is that Bottom() is the first item to have been pushed and the last item that would be popped. You are correct that the root transform should be closest to the first item pushed and it looks like that is Top() based on the implementation of the MutatorsStack, but that seems backwards to me and why I thought that the original code was correct.
Should the implementations of Bottom() and Top() be reversed?
Yes, the naming doesn't sound ideal. I'll leave this as a follow-up for Chinmay as I'm currently focusing on fixing functionality.
Sounds good. You might have to update an existing test expectation for this.
Sounds good. |
The mutator list sent to the embedder is in reverse order from the MutatorsStack. The root display transformation then needs to be appended at the end of the list. Given that these transforms are applied to a layer in display space the list needs to be reversed as well such that transforms can be applied in the right order to get from display space to surface space.
This is already in the mutator stack.
|
LUCI presubmits are infra failures and build_and_test_linux_unopt_debug covers the changes here. Landing to unblock b/143612326. |
flutter/engine@3488051...be20fb6 git log 3488051..be20fb6 --first-parent --oneline 2020-01-15 [email protected] [web] Exec command copy (flutter/engine#15675) 2020-01-15 [email protected] Disable fml_unittests till flakes are addressed. (flutter/engine#15676) 2020-01-15 [email protected] Roll src/third_party/dart fe666ce592cb..862d5012ae9c (48 commits) (flutter/engine#15672) 2020-01-15 [email protected] Fix hardware keyboard enter so it triggers an action. (flutter/engine#15568) 2020-01-15 [email protected] Use iOS 13 dark content status bar style (flutter/engine#13119) 2020-01-15 [email protected] Roll fuchsia/sdk/core/linux-amd64 from oxHfW... to UlOSN... (flutter/engine#15670) 2020-01-15 [email protected] Roll src/third_party/skia e45c5cd03eeb..7655168e6865 (29 commits) (flutter/engine#15671) 2020-01-15 [email protected] Fix embedder mutation order (flutter/engine#15566) 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] on the revert to ensure that a human is aware of the problem. To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
The mutator list sent to the embedder is in reverse order from the MutatorsStack. The root display transformation then needs to be appended at the end of the list. Given that these transforms are applied to a layer in display space the list needs to be reversed as well such that transforms can be applied in the right order to get from display space to surface space. Bug: b/143612326
This reverts commit 40dac82.
The mutator list sent to the embedder is in reverse order from the MutatorsStack. The root display transformation then needs to be appended at the end of the list. Given that these transforms are applied to a layer in display space the list needs to be reversed as well such that transforms can be applied in the right order to get from display space to surface space. Bug: b/143612326
The mutator list sent to the embedder is in reverse order from the
MutatorsStack. The root display transformation then needs to be appended
at the end of the list.
Given that these transforms are applied to a layer in display space the
list needs to be reversed as well such that transforms can be applied in
the right order to get from display space to surface space.
Bug: b/143612326