Open arnoldc opened 1 month ago
this below is the Android 15 (pixel 6a) - Emulator version but still its same with physical device , but idk why android 14 and android 15 has different height but it same model??
Same for me on Pixel 6 API 34 vs Pixel 6 API 35 Using height from useWindowDimensions() : Pixel 6 API 34 height => 841.5238..... Pixel 6 API 35 height => 914.2857.....
not sure but i think it was the bump of height in the bar found in the bottom of devices for pixel devices , idk 🤷 if im correct
I also use the hook useWindowDimensions
height value
-> e.g const {height, width, scale, fontScale} = useWindowDimensions();
, and the differences is much bigger now , i think there is an issue with calculating the dimension for android 15? any thoughts on this?
@alanleedev could you take a look at this one when you have a minute?
@cortinico
This behavior is not well documented but seems like on Android 15 height for window and screen is returning the same.
Systems bars appear to be ignored.
Emulator screenshots. Left is Android 15 and right is Android 14 on same device type.
Looking into fixing this to match existing behavior.
Although we do not call this directly and is supposed to be deprecated since API 30 but there is some info in Display.getSize() documentation which may be relevant: https://developer.android.com/reference/android/view/Display#getSize(android.graphics.Point)
- API level 35 and above, the window size will be returned.
- API level 34 and below, the window size minus system decoration areas and display cutout is returned.
I guess this could be correct if forced edge-to-edge is enabled. It does seem like same values is returned on Android 15 regardless of it is forced edge-to-edge or not. Seems like it could be bit tricky to handle and not completely sure if this is something we should try to fix.
What method could replace in place of Display.getSize() method ? If that is the case @alanleedev
so it seems bug in the api of react-native?, if thats the findings as well hmm what should be the workaround for the meantime
any suggestions?
thanks
so it seems bug in the api of react-native?, if thats the findings as well hmm what should be the workaround for the meantime
It is not a bug in react-native. It is actually how the Android API works currently. It behaves differently between Android 14 and Android 15. The question is should we do additional work on top of it to make it work like we expect it to. Doing this can get bit tricky is what I meant.
@mahishdino @arnoldc We do not actually call Display.getSize() directly. I just found hints on what could be happening in its doc. The code that does the widow or screen height calculation is DisplayMetricsHolder.kt.
We are discussion what we should do about this. Will update once we have direction.
Hi, thanks for the update. In the meantime, are there any good workarounds? This is impacting the placement of visual elements on our screens.
Hey folks, I plan to work on a fix to return the expected value. However curious to learn what everyone is using this for to see what kind of workaround we can recommend. @asherLZR @arnoldc
One example is, in a bottom sheet, the initial position starts off screen at Dimensions.get('window').height.
When the content is rendered, it gets translated in up to a maximum height also determined by some calculation based on Dimensions. There are also other gesture-based and scroll-based calculations which rely on a meaningful window height.
Naively, one approach for a workaround might be to know the height of the gesture bar, then deduct that from Dimensions.get('window').height
or Dimensions.get('screen').height
for only API 35. However, I'm not sure if this information is available or if the method is robust.
The only app side workaround that comes to mind at the moment is not to use the Dimensions API at all, but instead add a full screen absolute view (= having position: 'absolute', top: 0, left: 0, right: 0, bottom: 0
) e.g. in the app root that listens for the view's onLayout
callback, and store the event.nativeEvent.layout.height
reported by the onLayout-event, and use that value instead of the value reported by Dimensions API.
Side note, that same approach works as a workaround also for this issue: https://github.com/facebook/react-native/issues/41918
interestingly the Android docs imply that the transition should be enabling edge to edge display. However enabling edge-to-edge as per docs still result in different window size depending on OS version. Has anyone found success with it?
Having the same issue. Any updates on that?
Description
Hi React Native team
There seems to be issue with the latest Android 15 release,
The
Dimensions.get('window').height
seems not consistent in the model device Pixel6a , i think its same for other pixel devices which has latest android 15 recentlyI tried using the react native boiler plate which is running on 0.75.4 as you can see the numbers in the screenshot for height are different, so any idea whats causing the issue why Android 15 has different results from android 14, even if their model device is same?
Steps to reproduce
npx react-native init projectname
and begin running itReact Native Version
0.75.4
Affected Platforms
Runtime - Android
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://snack.expo.dev/@arnoldc/4dc13a
Screenshots and Videos
No response