Clean up old and unused implementation of microtasks (#40870)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40870

This removes an old experiment to implement microtasks in React Native (which is incorrect now that the runtime scheduler executes multiple tasks per runtime executor "task"). `drainMicrotasks` is a no-op at the moment in Hermes because the flag isn't set, so this code is essentially dead.

We'll add the new iteration of microtasks in a following PR.

Changelog: [internal]

Reviewed By: christophpurrer

Differential Revision: D49536251

fbshipit-source-id: b8efba2d0310b9e33e65b79c60ad2db1c8109def
This commit is contained in:
Rubén Norte 2023-10-18 06:14:25 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 7a5c47c4a3
Коммит 29bbab5a5a
2 изменённых файлов: 0 добавлений и 55 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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);
}