diff --git a/ReactCommon/fabric/uimanager/Scheduler.cpp b/ReactCommon/fabric/uimanager/Scheduler.cpp index c5bfe919340..40660ab91c0 100644 --- a/ReactCommon/fabric/uimanager/Scheduler.cpp +++ b/ReactCommon/fabric/uimanager/Scheduler.cpp @@ -91,10 +91,14 @@ void Scheduler::shadowTreeDidCommit(const ShadowTree &shadowTree, const ShadowVi #pragma mark - UIManagerDelegate void Scheduler::uiManagerDidFinishTransaction(Tag rootTag, const SharedShadowNodeUnsharedList &rootChildNodes) { - const auto &iterator = shadowTreeRegistry_.find(rootTag); - const auto &shadowTree = iterator->second; - assert(shadowTree); - return shadowTree->complete(rootChildNodes); + const auto iterator = shadowTreeRegistry_.find(rootTag); + if (iterator == shadowTreeRegistry_.end()) { + // This might happen during surface unmounting/deallocation process + // due to the asynchronous nature of JS calls. + return; + } + + return iterator->second->complete(rootChildNodes); } void Scheduler::uiManagerDidCreateShadowNode(const SharedShadowNode &shadowNode) {