Invalid negative/zero values returned by Dimensions API under iOS 15
See original GitHub issueDescription
Several of our users are reporting problems that we’ve found to be attributable to Dimensions.get(‘window’) erroneously returning 0 for width.
Version
0.63.4
Output of npx react-native info
info Fetching system and libraries information… System: OS: macOS 12.1 CPU: (16) x64 Intel® Core™ i9-9880H CPU @ 2.30GHz Memory: 1.89 GB / 32.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node Yarn: 1.17.3 - ~/qgenda.mobile/node_modules/.bin/yarn npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm Watchman: 2021.11.01.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /Users/beauwilkinson/.rbenv/shims/pod SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 Android SDK: Not Found IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7678000 Xcode: 13.2/13C5066c - /usr/bin/xcodebuild Languages: Java: 1.8.0_301 - /usr/bin/javac Python: 2.7.18 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.14.0 react-native: 0.63.4 => 0.62.3 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
Call Dimensions.get(‘window’).width on an iPhone 13 Pro Max (iPhone14,3) running iOS 15. The value obtained will be 0.
Snack, code example, screenshot, or link to a repository
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7
Top GitHub Comments
I’m facing the same issue on 0.62.3 and I think I found out why is that happening. This is the piece of the relevant code that figures out screen size on 0.62.3: https://github.com/facebook/react-native/blob/83425fa72f1f9a12f6b6deefd66fa8bd154a3651/React/UIUtils/RCTUIUtils.m#L19 And this was changed on a later version to: https://github.com/facebook/react-native/blob/8bd3edec88148d0ab1f225d2119435681fbbba33/React/UIUtils/RCTUIUtils.m#L20 as part of this commit: https://github.com/facebook/react-native/commit/e85372298109abf258d5154e2a28bc6496fb9529
so after I moved this changed to 0.62.3 this issue was resolved for me. Here is a patch file which you can run to fix this:
This issue was closed because it has been stalled for 7 days with no activity.