native-navigation
native-navigation copied to clipboard
[Android] Fix crash when current BackStack is null
At some point, the backStacks
object can be null, making backStacks.peek()
crash the app. I could not put my finger exactly on why this happens, but I suspect it's some kind of race condition. Anyway, it's always when trying to pop()
.
This PR does two things to address this problem:
- Adds a null check before trying to peek into our
backStacks
. - Logs a warning every time we would try to
pop
orpush
with a nullbackStacks
. That way we won't lose track of the problem.
This fixed the problem in our production app without any side effects but maybe somebody with more context on the code can clarify why this crash happens and whether this is an acceptable fix.