[0.63.1][Android] Dimensions API stops working randomly after a while
See original GitHub issuePlease provide all the information requested. Issues that do not follow this format are likely to stall.
Description
Using Dimensions.get('window')
and Dimensions.addEventListener(...)
stops working/firing events randomly after a while.
I can’t figure out exactly what triggers the issue, but after the event listener stops firing, calling get
will also return incorrect values (e.g., portrait values even if in landscape). Note that the actual UI still works as expected (rotates/adjusts), but the Dimensions API just completely breaks.
After testing for a couple of hours, the bug seems to happen after a WebView is loaded (with https://github.com/react-native-community/react-native-webview). I can’t tell yet whether this was caused by an upgrade in the WebView library or react native itself. I will be linking this issue there as well.
React Native version:
Run react-native info
in your terminal and copy the results here.
info Fetching system and libraries information...
System:
OS: macOS 10.15.4
CPU: (4) x64 Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz
Memory: 108.54 MB / 8.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.16.3 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 23, 26, 28, 29
Build Tools: 28.0.3, 29.0.2
Android NDK: Not Found
IDEs:
Android Studio: 4.0 AI-193.6911.18.40.6626763
Xcode: 11.5/11E608c - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_121 - /usr/bin/javac
Python: 2.7.15 - /Library/Frameworks/Python.framework/Versions/2.7/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: 0.63.1 => 0.63.1
npmGlobalPackages:
*react-native*: Not Found
Steps To Reproduce
Provide a detailed list of steps that reproduce the issue.
- Build a simple Android app with unlocked orientation (that is, allow all orientations)
- Use Dimensions API:
Dimensions.get('window')
andDimensions.addEventListener(...)
. For example, registering these on the root’s component mount. - Rotate the device a few times and confirm Dimensions is firing the event
- Mount a
<WebView />
component and rotate a few times - Unmount the
<WebView />
component - Rotate the device again. Observe how Dimensions events no longer fire, and
Dimensions.get(...)
always return the same values (i.e., they do not update when the UI rotates).
Some logcat warnings when the issue triggers:
2020-07-21 11:35:44.549 30678-31115/com.zinspector3.dev W/cr_media: Requires BLUETOOTH permission
2020-07-21 11:35:44.728 30678-31121/com.zinspector3.dev W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
2020-07-21 11:35:44.728 30678-31121/com.zinspector3.dev W/VideoCapabilities: Unrecognized profile 2130706434 for video/avc
2020-07-21 11:35:44.738 30678-31121/com.zinspector3.dev W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
2020-07-21 11:35:44.738 30678-31121/com.zinspector3.dev W/VideoCapabilities: Unrecognized profile 2130706434 for video/avc
2020-07-21 11:35:44.829 30678-31121/com.zinspector3.dev W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
2020-07-21 11:35:44.829 30678-31121/com.zinspector3.dev W/VideoCapabilities: Unrecognized profile 2130706434 for video/avc
2020-07-21 11:35:44.858 30678-31121/com.zinspector3.dev I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
-- close webview --
2020-07-21 11:41:34.078 31308-31308/com.zinspector3.dev E/chromium: [ERROR:aw_browser_terminator.cc(125)] Renderer process (32010) crash detected (code -1).
Note: react-navigation is also being used.
Expected Results
Dimensions API should not stop updating just because a possibly buggy component (WebView) is messing with the app.
Snack, code example, screenshot, or link to a repository:
Please provide a Snack (https://snack.expo.io/), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. You may provide a screenshot of the application if you think it is relevant to your bug report. Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve
Issue Analytics
- State:
- Created 3 years ago
- Reactions:15
- Comments:40 (12 by maintainers)
Top GitHub Comments
The fix for this is checked into the master branch (thank you @ajpaulingalls and @ejanzer) and will naturally make its way into the first react-native@0.64 release candidates. If you want it to be included in the future react-native@0.63.4 patch release, please upvote the comment linked below.
https://github.com/react-native-community/releases/issues/212#issuecomment-725612630
Still an issue, and RN 0.64 is just around the corner. This issue could really use some attention since migration is impossible until this is resolved and apps will already lag behind with RN updates.