Closed Yonom closed 2 years ago
Test this PR, maybe is related https://github.com/expo/expo/pull/15019 I fixed an issue with notifications on iOS with that. I created a patch here: https://github.com/expo/expo/issues/14078#issuecomment-959742553
please try to upgrade expo-updates@0.10.12
with #15019 change and see if it fix the issue for you. thanks for reporting this issue to us.
@Kudo Yes, I can confirm that hooks are no longer executed twice. Thanks for the fix 👍
i'm glad to hear that. thank you, @Yonom!
Summary
We are experiencing a series of strange issues after upgrading to SDK 43.
They all seem to stem from the fact that the app is mounted twice on launch in production builds, causing all hooks and everything to be run twice.
These issues are severe enough to make our app unusable around 90% of the time (some issues happen consistently, while others come and go). Moreover, the issues stem from race conditions that are super hard to debug, reproduce or work around.
Managed or bare workflow? If you have
ios/
orandroid/
directories in your project, the answer is bare!bare
What platform(s) does this occur on?
iOS
SDK Version (managed workflow only)
43.0.0
Environment
Reproducible demo or steps to reproduce from a blank project
Test 1 (baseline, expected behavior)
expo init -y
,yarn install
expo doctor
, fix all mismatchesexpo run:ios --configuration Release
✅ Output looks alright.
Test 2 (upgrade to SDK 43, this is where the issues begin)
expo upgrade
rm -r ./ios
expo run:ios --configuration Release
🤔 There are two instances of the application being started. There are warnings regarding
Unbalanced calls start/end for tag X
.Test 3 (add app_open useEffect hook)
Open
App.js
and apply the following diffuseEffect(() => {
// log something only once
console.log('app_open');
return () => console.log('app_close');
}, []);
expo run:ios --configuration Release
Open the app in simulator and check logs in flipper
:x: Our useEffect is run twice, app_open is logged twice. (Expectation: app_open is logged only once)
:x: The first useEffect is not cleaned up before the second one is run; there is no
app_close
event logged.Test 4 (react-native-firebase)
(this is an example of a module that breaks because of these changes)
test/doc
and make sure everyone has access to the document.@react-native-firebase/app
and setup the corresponding config plugin + Google-Info.plist@ract-native-firebase/firestore
App.js
and apply the following diffexpo run:ios --configuration Release
❌ Sometimes, when a race condition happens, the first invisible app instance gets the snapshot and the second app is stuck in "Waiting for snapshot" state. Other times, the order is reversed and the second app gets the snapshot, resulting in the expected behavior. (This is somewhat tricky to reproduce, the timings seem to be different based on the device model, app size, jsRuntime, ...)
👎 Bad case:
👍 Good case:
Other libraries that have issues
We are experiencing weird race conditions from
@react-native-async-storage/async-storage
(await AsyncStorage.getItem(key);
sometimes never resolving on first app launch),mixpanel-react-native
(internal SQLite table errors) and probably more to be discovered.Another interesting log we get is
EXUpdates: Could not emit noUpdateAvailable event. Did you set the bridge property on the controller singleton?