react-native-screens: RNScreenContainer crashes on iOS while in the background
Description
RNScreenContainer crashes, as per below, while the app is in the background. The error happens at random times (i.e. not immediately before/after backgrounding the app), presumably when our background task kicks in. I unfortunately haven’t been able to reproduce yet…
OS Version: iOS 14.4.2 (18D70)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Crashed Thread: 0
Application Specific Information:
*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
Thread 0 Crashed:
0 CoreFoundation 0x30881986c __exceptionPreprocess
1 libobjc.A.dylib 0x33296ac4c objc_exception_throw
2 CoreFoundation 0x308889e18 _CFThrowFormattedException
3 CoreFoundation 0x3088872fc -[__NSArrayM insertObject:atIndex:].cold.1
4 CoreFoundation 0x3086f6b8c -[__NSArrayM insertObject:atIndex:]
5 UIKitCore 0x30c9c1518 -[UIViewController _addChildViewController:performHierarchyCheck:notifyWillMove:]
6 GreenTriangle 0x202faf204 -[RNSScreenContainerView attachScreen:atIndex:] (RNSScreenContainer.m:144)
7 GreenTriangle 0x202faf72c -[RNSScreenContainerView updateContainer] (RNSScreenContainer.m:189)
8 GreenTriangle 0x202fafe58 __41-[RNSScreenContainerManager markUpdated:]_block_invoke (RNSScreenContainer.m:276)
Package versions
react-native-screens@3.2.0 react-native@0.64.1 react@17.0.1
It has been happening since our previous release, on: react-native-screens@2.17.1 react-native@0.63.4 react@16.13.1
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 5
- Comments: 21 (6 by maintainers)
Commits related to this issue
- revert: async container update (#986) PR reverting async container update on iOS (#777) since it caused multiple problems: - #905 https://github.com/software-mansion/react-native-screens/issues/90... — committed to software-mansion/react-native-screens by WoLewicki 3 years ago
- revert: async container update (#986) PR reverting async container update on iOS (#777) since it caused multiple problems: - #905 https://github.com/software-mansion/react-native-screens/issues/90... — committed to robertomartinez09515/native-mansion-screen-react by robertomartinez09515 3 years ago
- revert: async container update (#986) PR reverting async container update on iOS (#777) since it caused multiple problems: - #905 https://github.com/software-mansion/react-native-screens/issues/90... — committed to mccoyplayer/reactScreen by WoLewicki 3 years ago
@WoLewicki Sorry, I am not getting this issue on my local machine but it is getting by some users on production
If it help, we are also experiencing the exact same crash.
Same as above most crashes happen after app comes to foreground from background.
We are currently using: react-navigation/bottom-tabs:@5.11.8 react-navigation/native@^5.9.3 react-navigation/stack@^5.14.3 react-native-screens@3.1.1 react-native@0.64.0 react@17.0.1
Edit: we’re seeing another issue related to this
EXC_BAD_ACCESS Exception 1, Code 458777608, Subcode 8 > Attempted to dereference garbage pointer 0xa5991b586408.
@fedeerbes React Navigation documentation recommends conditionally removing screens but not stacks eg.
Quote from docs
See “Best practices when nesting” in React Navigation documentation and the “Authentication flow” if you have the time. Cheers!
I am using RN@0.66, reanimated@2.3.1, and react-native-screens@3.10.1 and having the same issue from the sentry log but it is triggering from
react-native-screens
@kacperkapusciak in my case at least, I was conditionally removing the entire navigator. In either case: I would hope that a crash is unwarranted, that it would be better to at least “catch” the underlying behavior and throw an error…?
In my case, this error went away, after: