-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Fix Dimensions window values on Android < 15 #52738
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
Conversation
|
@zoontek can you look into the test failures as they look related? |
|
Specifically the first one: |
|
@cortinico It should fix it. Thing is, the issue is that we cannot delay display metrics init until we get a non-null So we need to make subsequent calls to |
|
@cortinico has imported this pull request. If you are a Meta employee, you can view this in D78738516. |
f191ace to
e9ac31c
Compare
|
Hey @cortinico I wasn't super happy with the first proposed solution, did some extensive testing on Android 7 / 9 / 14, on old and new architecture (zoontek#2) Like suggested on Discord:
So:
demo.mp4 |
|
hey folks, is there any chance this to be backported to 0.79.x? Seems like a big issue in the UI consistency. Thanks! |
|
@zoontek Wanted to give you an update. I fixed some internal build errors but see this failing some tests. I haven't got around to look into it yet and want to be more cautious with this diff as past attempts has caused issues for us. Will try to get to this soon. |
|
@alanleedev has imported this pull request. If you are a Meta employee, you can view this in D78738516. |
|
@zoontek Noticing the implementation changed a bit since we first imported this PR. What is the reason for splitting |
|
@alanleedev Since Previously, both were initialized in the same method: I initially added a new check, In the end, instead of relying on a suite of conditions, I opted to split the initialization into two separate methods. This makes the code much easier to maintain and reason about. |
|
@zoontek I think the current PR adds behavior change which we may not be handled correctly. |
|
@alanleedev I think that some Let me have a look. Do you know how can I reproduce? |
# Conflicts: # packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java # packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/DisplayMetricsHolder.kt
60e278c to
d618835
Compare
|
@zoontek It is with internal Meta app so you probably cannot repro. I'll have further look into this. |
|
@alanleedev If an additional |
@zoontek App in question is partially RN and uses Fragments so will need to understand how things get initialized. But overall, PixelUtil has an unclear initialization dependency on DiplayMetricsHolder.windowDisplayMetrics which does not seem too desirable so wondering if there is a better way to handle this. |
|
@alanleedev Nearly all calls to The only valid usage is located in |
@zoontek That is a good point. Looking at TypedValue.java following seems to be used;
|
|
@alanleedev merged this pull request in 3b185e4. |
Summary: Reverting PR facebook#52738 Changelog: [Internal] reverting D78738516 Original commit changeset: fdb22f3cc76b Original Phabricator Diff: D78738516 Rollback Plan: Differential Revision: D79835424
Summary: Reverting PR facebook#52738 Changelog: [Internal] reverting D78738516 Original commit changeset: fdb22f3cc76b Original Phabricator Diff: D78738516 Reviewed By: lenaic, Abbondanzo Differential Revision: D79835424
Summary: Pull Request resolved: facebook#53149 Reverting PR facebook#52738 Changelog: [Internal] reverting D78738516 Original commit changeset: fdb22f3cc76b Original Phabricator Diff: D78738516 Reviewed By: mdvacca, lenaic, Abbondanzo Differential Revision: D79835424
Summary: Reverting PR facebook#52738 Changelog: [Internal] reverting D78738516 Original commit changeset: fdb22f3cc76b Original Phabricator Diff: D78738516 Reviewed By: mdvacca, lenaic, Abbondanzo Differential Revision: D79835424
Summary: Pull Request resolved: facebook#53149 Reverting PR facebook#52738 Changelog: [Internal] reverting D78738516 Original commit changeset: fdb22f3cc76b Original Phabricator Diff: D78738516 Reviewed By: mdvacca, lenaic, Abbondanzo Differential Revision: D79835424
Summary: Pull Request resolved: #53149 Reverting PR #52738 Changelog: [Internal] reverting D78738516 Original commit changeset: fdb22f3cc76b Original Phabricator Diff: D78738516 Reviewed By: mdvacca, lenaic, Abbondanzo Differential Revision: D79835424 fbshipit-source-id: 44b5ee34b4df6752e5a6f959a54e104eef20ffca
|
This pull request has been reverted by 352e440. |
Summary: This PR (initially created for edge-to-edge opt-in support, rebased multiple times) fixes the `Dimensions` API `window` values on Android < 15, when edge-to-edge is enabled. Currently the window height doesn't include the status and navigation bar heights (but it does on Android >= 15): <img width="300" alt="Screenshot 2025-06-27 at 16 23 02" src="https://github.com/user-attachments/assets/c7d11334-9298-4f7f-a75c-590df8cc2d8a" /> Using `WindowMetricsCalculator` from AndroidX: <img width="300" alt="Screenshot 2025-06-27 at 16 34 01" src="https://github.com/user-attachments/assets/7a4e3dc7-a83b-421b-8f6d-fd1344f5fe81" /> Fixes facebook#47080 ## Changelog: [Android] [Fixed] Fix `Dimensions` `window` values on Android < 15 when edge-to-edge is enabled Pull Request resolved: facebook#52738 Test Plan: Run the example app on an Android < 15 device. Rollback Plan: Reviewed By: cipolleschi, Abbondanzo Differential Revision: D78738516 Pulled By: alanleedev fbshipit-source-id: fdb22f3cc76b0bda987db426cb015124bcacdc84
Summary: Pull Request resolved: facebook#53149 Reverting PR facebook#52738 Changelog: [Internal] reverting D78738516 Original commit changeset: fdb22f3cc76b Original Phabricator Diff: D78738516 Reviewed By: mdvacca, lenaic, Abbondanzo Differential Revision: D79835424 fbshipit-source-id: 44b5ee34b4df6752e5a6f959a54e104eef20ffca
Summary:
This PR (initially created for edge-to-edge opt-in support, rebased multiple times) fixes the
DimensionsAPIwindowvalues on Android < 15, when edge-to-edge is enabled.Currently the window height doesn't include the status and navigation bar heights (but it does on Android >= 15):
Using
WindowMetricsCalculatorfrom AndroidX:Fixes #47080
Changelog:
[Android] [Fixed] Fix
Dimensionswindowvalues on Android < 15 when edge-to-edge is enabledTest Plan:
Run the example app on an Android < 15 device.