Skip to content

Commit

Permalink
Set up experiment to dispatch promise methods asynchronously to Nativ…
Browse files Browse the repository at this point in the history
…eModules thread

Summary:
TurboModule methods that return promises are synchronously run on the JavaScript thread. Back in D22489338 (9c35b5b), we wrote code to make them dispatch on the NativeModules thread. That code, however, was just left disabled. In this diff, I wire up the TurboModules infra to a MobileConfig, which should allow us to assess the performance impact of async dispatch of promise methods to the NativeModules thread in production, before we roll it out more widely.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24685389

fbshipit-source-id: 8ceb2e6effc125abecfa76e5e90bd310676aefc9
  • Loading branch information
RSNara authored and facebook-github-bot committed Nov 6, 2020
1 parent 1ee406b commit 052e578
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class ReactFeatureFlags {
*/
public static volatile boolean useTurboModules = false;

/** Should we dispatch TurboModule methods with promise returns to the NativeModules thread? */
public static volatile boolean enableTurboModulePromiseAsyncDispatch = false;

/*
* This feature flag enables logs for Fabric
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.facebook.react.bridge.JSIModule;
import com.facebook.react.bridge.JavaScriptContextHolder;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder;
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
import com.facebook.react.turbomodule.core.interfaces.TurboModuleRegistry;
Expand Down Expand Up @@ -60,7 +61,7 @@ public TurboModuleManager(
(CallInvokerHolderImpl) jsCallInvokerHolder,
(CallInvokerHolderImpl) nativeCallInvokerHolder,
delegate,
false);
ReactFeatureFlags.enableTurboModulePromiseAsyncDispatch);
installJSIBindings();

mEagerInitModuleNames =
Expand Down

0 comments on commit 052e578

Please sign in to comment.