Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -267,8 +243,6 @@ void JSIExecutor::callFunction(
std::runtime_error("Error calling " + moduleId + "." + methodId));
}

performMicrotaskCheckpoint(*runtime_);

callNativeModules(ret, true);
}

Expand All @@ -288,8 +262,6 @@ void JSIExecutor::invokeCallback(
folly::to<std::string>("Error invoking callback ", callbackId)));
}

performMicrotaskCheckpoint(*runtime_);

callNativeModules(ret, true);
}

Expand Down Expand Up @@ -426,7 +398,6 @@ void JSIExecutor::flush() {
SystraceSection s("JSIExecutor::flush");
if (flushedQueue_) {
Value ret = flushedQueue_->call(*runtime_);
performMicrotaskCheckpoint(*runtime_);
callNativeModules(ret, true);
return;
}
Expand All @@ -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
Expand Down
25 changes: 0 additions & 25 deletions packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -91,7 +67,6 @@ ReactInstance::ReactInstance(
if (auto strongTimerManager = weakTimerManager.lock()) {
strongTimerManager->callReactNativeMicrotasks(*strongRuntime);
}
performMicrotaskCheckpoint(*strongRuntime);
} catch (jsi::JSError& originalError) {
handleJSError(*strongRuntime, originalError, true);
}
Expand Down