Skip to content

Fix matrix multiplication logic for transforms#10112

Merged
4 commits merged intomicrosoft:mainfrom
rozele:issue10111
Jun 15, 2022
Merged

Fix matrix multiplication logic for transforms#10112
4 commits merged intomicrosoft:mainfrom
rozele:issue10111

Conversation

@rozele
Copy link
Contributor

@rozele rozele commented Jun 14, 2022

Fixes #10111

Description

Type of Change

Erase all that don't apply.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Why

As reported in #10111, float4x4's operator* does not produce the same output as expected on other RN platforms.

Resolves #10111

What

This change ports the logic from RN's MatrixMath.js to ensure multiplication of transforms produces the same result on Windows as on iOS and Android.

Screenshots

Before After iOS
image image Screen Shot 2022-06-14 at 1 04 06 PM
image image Screen Shot 2022-06-14 at 1 06 04 PM

One more for good measure - notice that the JS driven animation just sends transform props (rather than computed matrix) now that we forked processTransform.windows.js, so the animation doesn't match expectations from the native driver / iOS:

Before:

React.Native.Playground.Win32.2022-06-14.13-30-28.mp4

After:

playground.2022-06-14.13-30-13.mp4

iOS:

Screen.Recording.2022-06-14.at.1.35.15.PM.mov

Testing

See screenshots / recordings above, confirmed that transforms compose as expected on iOS.

Microsoft Reviewers: Open in CodeFlow

As reported in microsoft#10111, float4x4's operator* does not produce the same
output as expected on other RN platforms. This change ports the logic
from RN's MatrixMath.js to ensure multiplication of transforms produces
the same result on Windows as on iOS and Android.

Fixes microsoft#10111
@rozele rozele requested review from a team as code owners June 14, 2022 17:21
@rozele rozele added Area: Animation Area: View Managers Area: View Style Props https://reactnative.dev/docs/view-style-props labels Jun 14, 2022
@acoates-ms acoates-ms added the AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity) label Jun 14, 2022
@ghost
Copy link

ghost commented Jun 14, 2022

Hello @acoates-ms!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

Do note that I've been instructed to only help merge pull requests of this repository that have been opened for at least 10 hours, a condition that will be fulfilled in about 9 hours 2 minutes. No worries though, I will be back when the time is right! 😉

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@acoates-ms acoates-ms removed the AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity) label Jun 14, 2022
Copy link
Member

@asklar asklar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

marking requesting changes so we can understand where the difference is coming from

@ghost ghost added Needs: Author Feedback The issue/PR needs activity from its author (label drives bot activity) and removed Needs: Author Feedback The issue/PR needs activity from its author (label drives bot activity) labels Jun 14, 2022
@rozele
Copy link
Contributor Author

rozele commented Jun 14, 2022

marking requesting changes so we can understand where the difference is coming from

Thanks @asklar. It was indeed an issue with ordering, iOS and Android multiply in the reverse order. Fixed, but left the MultiplyInto helper so hopefully future transform types do not mess up the argument order for multiplication.

Happy to not use the helper, reverse the order of arguments for MultiplyInto, or otherwise make it very clear that we should use the new transform as the first operand and the current composition of transforms for the second based on whatever suggestion you might have :).

I also found it quite strange that we would need to reimplement matrix multiply.

@asklar asklar changed the title Uses custom matrix multiplication logic for transforms Fix matrix multiplication logic for transforms Jun 14, 2022
@acoates-ms
Copy link
Contributor

@rozele , any chance you can port this to the 0.69 branch too?

@ghost ghost merged commit 7f6367f into microsoft:main Jun 15, 2022
rozele added a commit to rozele/react-native-windows that referenced this pull request Jun 15, 2022
* Uses custom matrix multiplication logic for transforms

As reported in microsoft#10111, float4x4's operator* does not produce the same
output as expected on other RN platforms. This change ports the logic
from RN's MatrixMath.js to ensure multiplication of transforms produces
the same result on Windows as on iOS and Android.

Fixes microsoft#10111

* yarn format

* Change files

* Use float4x4 operator* but get the order correct
@rozele
Copy link
Contributor Author

rozele commented Jun 15, 2022

@acoates-ms done - #10121

acoates-ms pushed a commit that referenced this pull request Jun 15, 2022
* Uses custom matrix multiplication logic for transforms

As reported in #10111, float4x4's operator* does not produce the same
output as expected on other RN platforms. This change ports the logic
from RN's MatrixMath.js to ensure multiplication of transforms produces
the same result on Windows as on iOS and Android.

Fixes #10111

* yarn format

* Change files

* Use float4x4 operator* but get the order correct
rozele added a commit to rozele/react-native-windows that referenced this pull request Oct 23, 2022
* Uses custom matrix multiplication logic for transforms

As reported in microsoft#10111, float4x4's operator* does not produce the same
output as expected on other RN platforms. This change ports the logic
from RN's MatrixMath.js to ensure multiplication of transforms produces
the same result on Windows as on iOS and Android.

Fixes microsoft#10111

* yarn format

* Change files

* Use float4x4 operator* but get the order correct
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transforms no longer compose correctly

3 participants