From 40adcbac87fac9c5ca4cee8e29d9290ac75ca8bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Mon, 23 Oct 2023 05:55:11 -0700 Subject: [PATCH] Wire up configuration to use microtasks in RuntimeScheduler, Hermes and React (#41090) Summary: This propagates to enable the use of microtasks in the React reconciler, Runtime Scheduler and Hermes. Changelog: [internal] Reviewed By: sammy-SC Differential Revision: D50177355 --- .../react/renderer/scheduler/Scheduler.cpp | 8 ++++++++ .../react/runtime/hermes/HermesInstance.cpp | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp index b52841fb8ea322..df3c9ada438899 100644 --- a/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -139,6 +139,14 @@ Scheduler::Scheduler( reduceDeleteCreateMutationLayoutAnimation_ = true; #endif +#ifdef ANDROID + CoreFeatures::enableMicrotasks = + reactNativeConfig_->getBool("react_fabric:enable_microtasks_android"); +#else + CoreFeatures::enableMicrotasks = + reactNativeConfig_->getBool("react_fabric:enable_microtasks_ios"); +#endif + CoreFeatures::blockPaintForUseLayoutEffect = reactNativeConfig_->getBool( "react_fabric:block_paint_for_use_layout_effect"); diff --git a/packages/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp b/packages/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp index 55efa0eb6b5bc6..d682224485af81 100644 --- a/packages/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp +++ b/packages/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp @@ -105,6 +105,17 @@ std::unique_ptr HermesInstance::createJSRuntime( auto heapSizeMB = heapSizeConfig > 0 ? static_cast<::hermes::vm::gcheapsize_t>(heapSizeConfig) : 3072; + +#ifdef ANDROID + bool enableMicrotasks = reactNativeConfig + ? reactNativeConfig->getBool("react_fabric:enable_microtasks_android") + : false; +#else + bool enableMicrotasks = reactNativeConfig + ? reactNativeConfig->getBool("react_fabric:enable_microtasks_ios") + : false; +#endif + ::hermes::vm::RuntimeConfig::Builder runtimeConfigBuilder = ::hermes::vm::RuntimeConfig::Builder() .withGCConfig(::hermes::vm::GCConfig::Builder() @@ -119,6 +130,7 @@ std::unique_ptr HermesInstance::createJSRuntime( .build()) .withES6Proxy(false) .withEnableSampleProfiling(true) + .withMicrotaskQueue(enableMicrotasks) .withVMExperimentFlags(vmExperimentFlags); if (cm) {