From cd7cf07d32bcd22b030a695125cabafb8618e7b5 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Wed, 8 Jan 2025 14:21:30 +0000 Subject: [PATCH] [LOCAL][RN] Clean up feature flag --- .../src/main/jni/react/fabric/Binding.cpp | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/Binding.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/Binding.cpp index 3332d683ba6..2b9d616fcfe 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/Binding.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/Binding.cpp @@ -501,27 +501,25 @@ void Binding::schedulerShouldRenderTransactions( return; } - if (ReactNativeFeatureFlags:: - allowRecursiveCommitsWithSynchronousMountOnAndroid()) { - std::vector pendingTransactions; - { - // Retain the lock to access the pending transactions but not to execute - // the mount operations because that method can call into this method - // again. - std::unique_lock lock(pendingTransactionsMutex_); - pendingTransactions_.swap(pendingTransactions); - } + std::vector pendingTransactions; - for (auto& transaction : pendingTransactions) { - mountingManager->executeMount(transaction); - } - } else { + { + // Retain the lock to access the pending transactions but not to execute + // the mount operations because that method can call into this method + // again. + // + // This can be re-entrant when mounting manager triggers state updates + // synchronously (this can happen when committing from the UI thread). + // This is safe because we're already combining all the transactions for the + // same surface ID in a single transaction in the pending transactions list, + // so operations won't run out of order. std::unique_lock lock(pendingTransactionsMutex_); - for (auto& transaction : pendingTransactions_) { - mountingManager->executeMount(transaction); - } - pendingTransactions_.clear(); + pendingTransactions_.swap(pendingTransactions); + } + + for (auto& transaction : pendingTransactions) { + mountingManager->executeMount(transaction); } }