From 69bf98f48803bde8f203b42582c00ca84f60db25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= <rubennorte@fb.com> Date: Tue, 17 Oct 2023 10:22:51 -0700 Subject: [PATCH] Clean up old and unused implementation of microtasks Differential Revision: D49536251 fbshipit-source-id: e987dec21cf45220d329c6eb0583b1a3ee01e420 --- .../jsiexecutor/jsireact/JSIExecutor.cpp | 30 ------------------- .../react/runtime/ReactInstance.cpp | 25 ---------------- 2 files changed, 55 deletions(-) diff --git a/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp b/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp index 279e45a056d17c..51fabddc8f0f03 100644 --- a/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp +++ b/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp @@ -208,30 +208,6 @@ void JSIExecutor::registerBundle( ReactMarker::REGISTER_JS_SEGMENT_STOP, tag.c_str()); } -// Looping on \c drainMicrotasks until it completes or hits the retries bound. -static void performMicrotaskCheckpoint(jsi::Runtime& runtime) { - uint8_t retries = 0; - // A heuristic number to guard infinite or absurd numbers of retries. - const static unsigned int kRetriesBound = 255; - - while (retries < kRetriesBound) { - try { - // The default behavior of \c drainMicrotasks is unbounded execution. - // We may want to make it bounded in the future. - if (runtime.drainMicrotasks()) { - break; - } - } catch (jsi::JSError& error) { - handleJSError(runtime, error, true); - } - retries++; - } - - if (retries == kRetriesBound) { - throw std::runtime_error("Hits microtasks retries bound."); - } -} - void JSIExecutor::callFunction( const std::string& moduleId, const std::string& methodId, @@ -267,8 +243,6 @@ void JSIExecutor::callFunction( std::runtime_error("Error calling " + moduleId + "." + methodId)); } - performMicrotaskCheckpoint(*runtime_); - callNativeModules(ret, true); } @@ -288,8 +262,6 @@ void JSIExecutor::invokeCallback( folly::to<std::string>("Error invoking callback ", callbackId))); } - performMicrotaskCheckpoint(*runtime_); - callNativeModules(ret, true); } @@ -426,7 +398,6 @@ void JSIExecutor::flush() { SystraceSection s("JSIExecutor::flush"); if (flushedQueue_) { Value ret = flushedQueue_->call(*runtime_); - performMicrotaskCheckpoint(*runtime_); callNativeModules(ret, true); return; } @@ -444,7 +415,6 @@ void JSIExecutor::flush() { // get the pending queue of native calls. bindBridge(); Value ret = flushedQueue_->call(*runtime_); - performMicrotaskCheckpoint(*runtime_); callNativeModules(ret, true); } else if (delegate_) { // If we have a delegate, we need to call it; we pass a null list to diff --git a/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp b/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp index 0f85cf0b722a1b..abfda3b74a41ab 100644 --- a/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp +++ b/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp @@ -24,30 +24,6 @@ namespace facebook::react { -// Looping on \c drainMicrotasks until it completes or hits the retries bound. -static void performMicrotaskCheckpoint(jsi::Runtime& runtime) { - uint8_t retries = 0; - // A heuristic number to guard inifinite or absurd numbers of retries. - constexpr unsigned int kRetriesBound = 255; - - while (retries < kRetriesBound) { - try { - // The default behavior of \c drainMicrotasks is unbounded execution. - // We may want to make it bounded in the future. - if (runtime.drainMicrotasks()) { - break; - } - } catch (jsi::JSError& error) { - handleJSError(runtime, error, true); - } - retries++; - } - - if (retries == kRetriesBound) { - throw std::runtime_error("Hits microtasks retries bound."); - } -} - ReactInstance::ReactInstance( std::unique_ptr<jsi::Runtime> runtime, std::shared_ptr<MessageQueueThread> jsMessageQueueThread, @@ -91,7 +67,6 @@ ReactInstance::ReactInstance( if (auto strongTimerManager = weakTimerManager.lock()) { strongTimerManager->callReactNativeMicrotasks(*strongRuntime); } - performMicrotaskCheckpoint(*strongRuntime); } catch (jsi::JSError& originalError) { handleJSError(*strongRuntime, originalError, true); }