[V3, Android] Catch rare RuntimeException in setRoot when waitForRender = true #5428
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've seen the following crash in production. It's rare, but it appears there's some kind of race condition in
setRoot
'saddOnAppearedListener
that results ingetView
throwing. Here's the stack trace:Instead of swallowing the exception here, I've decided to pass it to JS so it can be caught by wrapping
await setRoot()
in a try/catch. Interested to see if others agree with this approach, or whether it should just be swallowed.Importantly, I've observed this with RN 0.59.8 and RNN 2.22.3 as that's what I'm in production with, but I'm opening this PR against V3 so it has a chance of helping someone. Maybe someone with more knowledge of the Android view lifecycles in this library could comment on whether this is still necessary.
Thanks for the awesome library!