diff --git a/ReactCommon/react/renderer/mounting/ShadowTree.cpp b/ReactCommon/react/renderer/mounting/ShadowTree.cpp index 3a56b4631cc..fdfa5b990fd 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTree.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowTree.cpp @@ -332,7 +332,7 @@ CommitStatus ShadowTree::tryCommit( auto newRootShadowNode = transaction(*oldRevision.rootShadowNode); if (!newRootShadowNode || - (commitOptions.shouldCancel && commitOptions.shouldCancel())) { + (commitOptions.shouldYield && commitOptions.shouldYield())) { return CommitStatus::Cancelled; } @@ -372,7 +372,7 @@ CommitStatus ShadowTree::tryCommit( *this, oldRootShadowNode, newRootShadowNode); if (!newRootShadowNode || - (commitOptions.shouldCancel && commitOptions.shouldCancel())) { + (commitOptions.shouldYield && commitOptions.shouldYield())) { return CommitStatus::Cancelled; } diff --git a/ReactCommon/react/renderer/mounting/ShadowTree.h b/ReactCommon/react/renderer/mounting/ShadowTree.h index 8dd6dff7428..c459380e41e 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTree.h +++ b/ReactCommon/react/renderer/mounting/ShadowTree.h @@ -55,9 +55,10 @@ class ShadowTree final { struct CommitOptions { bool enableStateReconciliation{false}; - // Lambda called inside `tryCommit`. If false is returned, commit is - // cancelled. - std::function shouldCancel; + + // Called during `tryCommit` phase. Returning true indicates current commit + // should yield to the next commit. + std::function shouldYield; }; /* diff --git a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp index 2e1367be594..3dc2495bf7f 100644 --- a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp @@ -458,15 +458,15 @@ jsi::Value UIManagerBinding::get( mostRecentSurfaceId = surfaceId; sharedUIManager->backgroundExecutor_( [=, eventCount = completeRootEventCounter.load()] { - auto shouldCancel = [=]() -> bool { + auto shouldYield = [=]() -> bool { // If `completeRootEventCounter` was incremented, another // `completeSurface` call has been scheduled and current - // `completeSurface` should be cancelled. + // `completeSurface` should yield to it. return completeRootEventCounter > eventCount && mostRecentSurfaceId == surfaceId; }; sharedUIManager->completeSurface( - surfaceId, shadowNodeList, {true, shouldCancel}); + surfaceId, shadowNodeList, {true, shouldYield}); }); return jsi::Value::undefined();