SIGN IN SIGN UP
facebook / react-native UNCLAIMED

A framework for building native applications using React

0 0 0 C++

Fix a race condition in AppState that prevents listeners from being notified

Summary:
If someone has setup a subscription on AppState and we correct AppState via getCurrentAppState call, we need to notify all the subscribers of AppState.
1 ) Initial AppState.currentState = 'active'
2-start) Subscribe to AppState Changes
3-start) Fetch Current AppState
4 ) App Code subscribes to AppState module
5 ) App becomes backgrounded
2-finish) AppState listeners are setup (missing background event)
3-finish) AppState.currentState updated to background

At this point the subscription setup in 4) will never be called with the change.

AppState should always call subscribers on change

This is very difficult to formally test since it's due to a race condition. We've seen this condition via bug reports but have had no local repro.

[GENERAL][BUGFIX][AppState] - Fix a race condition that could prevent AppState subscription change listener from firing on initial launch
Closes https://github.com/facebook/react-native/pull/18236

Differential Revision: D7823370

Pulled By: hramos

fbshipit-source-id: 99b174df70262ceaf9da141d005131facd624594
B
Brent Erickson committed
f99ca3c03fbd92995ef2559198a8b7fa7721ca92
Parent: 0f6762b
Committed by Facebook Github Bot <[email protected]> on 5/1/2018, 1:01:17 AM