Fix Android coroutine scope cancellation causing promises to hang after React context reload#911
Conversation
|
|
hello and thanks for opening the PR!
that sounds odd to me, because the coroutine scope is created when the native module is created (=the first time it's called in JS). And after thank you! |
1 similar comment
|
hello and thanks for opening the PR!
that sounds odd to me, because the coroutine scope is created when the native module is created (=the first time it's called in JS). And after thank you! |
After React context reload, the document picker's coroutine scope was canceled in
onHostDestroy()but never recreated, causing subsequentlaunch {}calls to silently no-op and promises to never resolve.Changes
Scope lifecycle management:
fileCopyingCoroutinefromvaltovarto allow recreationcreateCoroutineScope(): constructs scope withSupervisorJob() + Dispatchers.IOensureScopeActive(reason): checksscope.isActivebefore launch, recreates if canceledUpdated coroutine launch sites:
processFilePickerResult()(critical path)keepLocalCopy()writeDocuments()Fixes: #907 #910