-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make perspective transformation look exactly same on iOS and Android #18302
Conversation
Generated by 🚫 dangerJS |
@syaau I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project. |
@syaau thanks for this PR. Unfortunately it is a bit hard through the test plan and code to understand what is changing here. Would you be able to provide some before/after screenshots that helps us understand your change? Thank you. |
@cpojer Please check the screenshots above, where you could see that the perspective values didn't work correctly in between the android devices with different pixel densities. After applying the fix, the output looks exactly the same with the iOS and irrespective of the Pixel Density. Above in the example code, I have applied the fix on the perspective value itself, whereas this pull request implements the same thing in android. I am not sure why the magic number 5 had been used previously to calculate the camera distance. I guess it has got something to do with the matrix that has been used for transformation. But sqrt(5) produced the same output as 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.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
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.
Thank you for the thorough explanation and the screenshots. I added a link to this Pull Request as a comment so that people can find more information if they come across this.
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.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
The perspective projection didn't match with iOS output and also differed on devices with different pixel density. While back calculating the perspective value from the generated output mathematically, the Camera Distance was coming out to be approx. 2.24 (sqrt 5) times the given perspective value (irrespective of the display density). After correcting the values, the perspective output matched exactly with the ios output with any screen density. Before this fix, as a work around I had to back-calculate the perspective value on android as: const PERSPECTIVE = Platform.OS === 'ios' ? P : P * PixelRatio.get() / 2.236;
Having a bit of a hiccup with the import right now but I'm gonna rebase this PR and will get it landed as soon as possible. |
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.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
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.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
…acebook#18302) Summary: There is a variation in iOS and Android output while performing perspective transformation. The variation exists even when used in Android devices with different screen density. Pull Request resolved: facebook#18302 Differential Revision: D13877483 Pulled By: cpojer fbshipit-source-id: e48be047a8047c7562722923a67666cb098243d8
Summary:
There is a variation in iOS and Android output while performing perspective transformation. The variation exists even when used in Android devices with different screen density.
Test Plan:
I carried out tests on multiple devices with different perspective value and varying rotation X angle, and back calculated the Camera Distance value from the screen shots. On iOS the values were almost equal to the
Pixel Density * Perspective
value wheres on Android devices the Distance would always come out to be approximately2.24 * Perspective
value irrespective of the device screen density. I used the following code to use perspective transformation and verified that output matched exactly on all platforms.The code was then translated to the
BaseViewManager.java
and verified that the output matched on all platforms.Changelog:
[ANDROID] [BUGFIX] [Perspective Transformation] - Corrected perspective transformation to look exactly same on iOS and Android devices.