From bb851574411699c4dd7e1fcb71a7580de9616032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20M=C4=85ka?= Date: Thu, 27 Jul 2023 12:39:42 +0200 Subject: [PATCH 1/4] Improved skipping commits --- Common/cpp/NativeModules/NativeReanimatedModule.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Common/cpp/NativeModules/NativeReanimatedModule.cpp b/Common/cpp/NativeModules/NativeReanimatedModule.cpp index 484de75256f..c106f0dcf6c 100644 --- a/Common/cpp/NativeModules/NativeReanimatedModule.cpp +++ b/Common/cpp/NativeModules/NativeReanimatedModule.cpp @@ -525,7 +525,8 @@ void NativeReanimatedModule::performOperations() { ReanimatedCommitMarker commitMarker; shadowTree.commit( - [&](RootShadowNode const &oldRootShadowNode) { + [&](RootShadowNode const &oldRootShadowNode) + -> RootShadowNode::Unshared { auto rootNode = oldRootShadowNode.ShadowNode::clone(ShadowNodeFragment{}); @@ -535,6 +536,10 @@ void NativeReanimatedModule::performOperations() { const ShadowNodeFamily &family = shadowNode->getFamily(); react_native_assert(family.getSurfaceId() == surfaceId_); + if (propsRegistry_->shouldSkipCommit()) { + return nullptr; + } + auto newRootNode = shadowTreeCloner.cloneWithNewProps( rootNode, family, RawProps(rt, *props)); @@ -551,7 +556,9 @@ void NativeReanimatedModule::performOperations() { return newRoot; }, - {/* default commit options */}); + {.shouldYield = [this]() { + return propsRegistry_->shouldSkipCommit(); + }}); }); } From e648c9b1aab6c5c277e16829b25899e42e0a0d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20M=C4=85ka?= Date: Tue, 8 Aug 2023 10:41:14 +0200 Subject: [PATCH 2/4] Fixed review comment --- Common/cpp/NativeModules/NativeReanimatedModule.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Common/cpp/NativeModules/NativeReanimatedModule.cpp b/Common/cpp/NativeModules/NativeReanimatedModule.cpp index c106f0dcf6c..4ff116ee182 100644 --- a/Common/cpp/NativeModules/NativeReanimatedModule.cpp +++ b/Common/cpp/NativeModules/NativeReanimatedModule.cpp @@ -556,9 +556,11 @@ void NativeReanimatedModule::performOperations() { return newRoot; }, - {.shouldYield = [this]() { - return propsRegistry_->shouldSkipCommit(); - }}); + {/* .enableStateReconciliation = */ false, + /* .mountSynchronously = */ true, + /* .shouldYield = */ [this]() { + return propsRegistry_->shouldSkipCommit(); + }}); }); } From 61fd7ace45139c4aef29d47ef57ad01e38a3c16c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20M=C4=85ka?= Date: Tue, 29 Aug 2023 09:41:46 +0200 Subject: [PATCH 3/4] Added returning nullptr from commit hook when RN>=0.73 --- Common/cpp/NativeModules/NativeReanimatedModule.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Common/cpp/NativeModules/NativeReanimatedModule.cpp b/Common/cpp/NativeModules/NativeReanimatedModule.cpp index 4ff116ee182..1c0ec415bfa 100644 --- a/Common/cpp/NativeModules/NativeReanimatedModule.cpp +++ b/Common/cpp/NativeModules/NativeReanimatedModule.cpp @@ -536,9 +536,14 @@ void NativeReanimatedModule::performOperations() { const ShadowNodeFamily &family = shadowNode->getFamily(); react_native_assert(family.getSurfaceId() == surfaceId_); +#if REACT_NATIVE_MINOR_VERSION >= 73 + // Fix for catching nullptr returned from commit hook was introduced + // in 0.72.4 but we have only check for minor version of React + // Native so enable that optimization in React Native >= 0.73 if (propsRegistry_->shouldSkipCommit()) { return nullptr; } +#endif auto newRootNode = shadowTreeCloner.cloneWithNewProps( rootNode, family, RawProps(rt, *props)); From db76081a70cbb2a7cd14af2009cfd221e4d98372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20M=C4=85ka?= Date: Tue, 29 Aug 2023 10:39:15 +0200 Subject: [PATCH 4/4] Fixed code after rebase --- Common/cpp/NativeModules/NativeReanimatedModule.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/cpp/NativeModules/NativeReanimatedModule.cpp b/Common/cpp/NativeModules/NativeReanimatedModule.cpp index 1c0ec415bfa..b6092f2e388 100644 --- a/Common/cpp/NativeModules/NativeReanimatedModule.cpp +++ b/Common/cpp/NativeModules/NativeReanimatedModule.cpp @@ -540,7 +540,7 @@ void NativeReanimatedModule::performOperations() { // Fix for catching nullptr returned from commit hook was introduced // in 0.72.4 but we have only check for minor version of React // Native so enable that optimization in React Native >= 0.73 - if (propsRegistry_->shouldSkipCommit()) { + if (propsRegistry_->shouldReanimatedSkipCommit()) { return nullptr; } #endif @@ -564,7 +564,7 @@ void NativeReanimatedModule::performOperations() { {/* .enableStateReconciliation = */ false, /* .mountSynchronously = */ true, /* .shouldYield = */ [this]() { - return propsRegistry_->shouldSkipCommit(); + return propsRegistry_->shouldReanimatedSkipCommit(); }}); }); }