Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@dnicoara
Copy link
Contributor

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

@auto-assign auto-assign bot requested a review from flar January 13, 2020 23:22
@flar
Copy link
Contributor

flar commented Jan 14, 2020

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.

@flar flar requested a review from chinmaygarde January 14, 2020 01:06
@dnicoara
Copy link
Contributor Author

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
[2] https://github.com/flutter/engine/blob/master/shell/platform/embedder/embedder.h#L731

@flar
Copy link
Contributor

flar commented Jan 14, 2020

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?

Copy link
Member

@chinmaygarde chinmaygarde left a 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.

Copy link
Contributor Author

@dnicoara dnicoara left a 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.

@chinmaygarde
Copy link
Member

Oh, interesting. Let me test. I'll likely want to fix this now rather than wait.

Sounds good. You might have to update an existing test expectation for this.

I'll leave this as a follow-up for Chinmay.

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.
@chinmaygarde
Copy link
Member

LUCI presubmits are infra failures and build_and_test_linux_unopt_debug covers the changes here. Landing to unblock b/143612326.

@chinmaygarde chinmaygarde merged commit 1d6766f into flutter:master Jan 15, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 16, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 16, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 16, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 16, 2020
engine-flutter-autoroll added a commit to flutter/flutter that referenced this pull request Jan 16, 2020
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
NoamDev pushed a commit to NoamDev/engine that referenced this pull request Feb 27, 2020
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
NoamDev added a commit to NoamDev/engine that referenced this pull request Feb 27, 2020
filmil pushed a commit to filmil/engine that referenced this pull request Mar 13, 2020
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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants