Description
After I migrated to 0.74, I found that Logcat was reporting an error:
Unhandled SoftException com. Facebook. react. bridge ReactNoCrashSoftException: Tried to access onWindowFocusChange while context is not ready
The AppState.addEventListener fn not triggered
Steps to reproduce
index.js
AppState.addEventListener('change', state => {
console.log(state);
});
- run app (android)
- make app to the background
React Native Version
0.74.0
Affected Platforms
Runtime - Android, Build - MacOS
Areas
JSI - Javascript Interface, Bridgeless - The New Initialization Flow
Output of npx react-native info
System:
OS: macOS 14.3.1
CPU: (10) arm64 Apple M1 Max
Memory: 1.39 GB / 64.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 18.19.0
path: ~/.nvm/versions/node/v18.19.0/bin/node
Yarn:
version: 1.22.22
path: ~/.nvm/versions/node/v18.19.0/bin/yarn
npm:
version: 10.2.3
path: ~/.nvm/versions/node/v18.19.0/bin/npm
Watchman:
version: 2021.11.15.00
path: /usr/local/bin/watchman
Managers:
CocoaPods:
version: 1.10.1
path: /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 21.4
- iOS 16.0
- macOS 12.3
- tvOS 16.0
- watchOS 9.0
Android SDK:
Android NDK: 22.1.7171670
IDEs:
Android Studio: 2023.2 AI-232.10300.40.2321.11567975
Xcode:
version: 14.0.1/14A400
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.1
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.74.0
wanted: ^0.74.0
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
(Because I am using PNPM, it shows none `Not found`)
Stacktrace or Logs
ReactHost{0}.onWindowFocusChange(hasFocus = "false")
Unhandled SoftException
com.facebook.react.bridge.ReactNoCrashSoftException: Tried to access onWindowFocusChange while context is not ready
at com.facebook.react.runtime.ReactHostImpl.onWindowFocusChange(ReactHostImpl.java:664)
at com.facebook.react.ReactDelegate.onWindowFocusChanged(ReactDelegate.java:193)
at com.facebook.react.ReactActivityDelegate.onWindowFocusChanged(ReactActivityDelegate.java:175)
at com.facebook.react.ReactActivity.onWindowFocusChanged(ReactActivity.java:128)
at androidx.appcompat.view.WindowCallbackWrapper.onWindowFocusChanged(WindowCallbackWrapper.java:125)
at com.android.internal.policy.DecorView.onWindowFocusChanged(DecorView.java:2422)
at android.view.View.dispatchWindowFocusChanged(View.java:15279)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:1566)
at android.view.ViewRootImpl.handleWindowFocusChanged(ViewRootImpl.java:4981)
at android.view.ViewRootImpl.access$1400(ViewRootImpl.java:270)
at android.view.ViewRootImpl$ViewRootHandler.handleMessageImpl(ViewRootImpl.java:7115)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:7009)
at android.os.Handler.dispatchMessage(Handler.java:117)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:293)
at android.app.ActivityThread.loopProcess(ActivityThread.java:9961)
at android.app.ActivityThread.main(ActivityThread.java:9950)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:586)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1240)
Reproducer
none
Screenshots and Videos
No response
Description
After I migrated to 0.74, I found that Logcat was reporting an error:
Unhandled SoftException com. Facebook. react. bridge ReactNoCrashSoftException: Tried to access onWindowFocusChange while context is not readyThe AppState.addEventListener fn not triggered
Steps to reproduce
index.jsReact Native Version
0.74.0
Affected Platforms
Runtime - Android, Build - MacOS
Areas
JSI - Javascript Interface, Bridgeless - The New Initialization Flow
Output of
npx react-native infoStacktrace or Logs
Reproducer
none
Screenshots and Videos
No response