-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
AppState 'change' fires redundant 'active' when app is already active the first time the listener is added on Android iOS Prod #45418
Comments
@ashwinkumar6 With new architecture enabled I found out that the way In order to debug this I put a log here Line 109 in 65a3259
For debug build: All the mentioned native modules constructors are being called on app load it self. In release builds: Only these SoundManager, NativeAnimatedModule, FrescoModule modules are being called on app load. Now because of this in debug build: In release builds: When we click on button to add an I checked AppStateModule here we are using TurboModules to register it. @cortinico I am just curious to know how it works differently in release and debug builds? |
All the native modules you find listed inside @shubhamguptadream11 if you add a log on I haven't investigated this further, but in Debug we do have more modules loaded (for example LogBoxes and the react-devtools debug overlay) which are not loaded in Release. That's most likely the reason why you see "less" calls to |
Hi @cortinico @shubhamguptadream11, Appreciate the quick response ! |
Description
On Android and iOS PROD when the AppState listener 'change' is added the very first time it automatically also fires the listener with nextState as "active" even though the app is already "active".
This issue occurs specifically on Prod and not Dev. On Dev it works as expected where the listener is not fired the first time it's added. listener is only fired the first time when the app goes to the background.
EXPECTED BEHAVIOR:
The behavior should be the same with dev and prod where the listener does not automatically fire with 'active' when it's added the very first time.
Steps to reproduce
npx react-native init androidAppStateIssue
addAppStateListener
button and notice that the listener is NOT automatically fired with "active" when the listener is added.console.log('INITIAL', AppState.currentState);
and rebuild, re-install app.addAppStateListener
button and notice that the listener IS automatically fired with "active" when the listener is addedReact Native Version
0.74.3 (current latest)
Affected Platforms
Other (please specify)
Android and iOS PROD
Output of
npx react-native info
Stacktrace or Logs
When listener is added for the first time in dev vs prod. (make sure to comment the
console.log('INITIAL', AppState.currentState)
on app)dev
prod
Reproducer
https://github.com/ashwinkumar6/androidAppStateIssue
Screenshots and Videos
No response
The text was updated successfully, but these errors were encountered: