Skip to content

Commit 29f9244

Browse files
SparshaSahajeongshin
authored andcommitted
Make setJSEngineResolutionAlgorithm a public method (facebook#36715)
Summary: `setJSEngineResolutionAlgorithm` is marked as private while it looks like it was intended to be public. While the current implementation does not cause any issues as such, but in brownfield we will have the option to explicitly set the JS engine to hermes or jsc when initialising the ReactInstanceBuilder. Right now, we look if the engine is set and if unset we look for the jsc engine. If jsc is not present we select hermes and this process unnecessary throws a warning. ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [ANDROID][FIXED] - Changed the scope of `setJSEngineResolutionAlgorithm` to public from private. Brownfield apps should be able to setup the JSResolutionAlgorithm before hand. Pull Request resolved: facebook#36715 Reviewed By: cortinico Differential Revision: D44535444 Pulled By: javache fbshipit-source-id: ae91e50de10c993c80ed4bba6f2fece64af178c4
1 parent c89237c commit 29f9244

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class ReactInstanceManagerBuilder {
6969
private @Nullable ReactPackageTurboModuleManagerDelegate.Builder mTMMDelegateBuilder;
7070
private @Nullable SurfaceDelegateFactory mSurfaceDelegateFactory;
7171
private @Nullable DevLoadingViewManager mDevLoadingViewManager;
72-
private JSEngineResolutionAlgorithm jsEngineResolutionAlgorithm = null;
72+
private @Nullable JSEngineResolutionAlgorithm mJSEngineResolutionAlgorithm = null;
7373

7474
/* package protected */ ReactInstanceManagerBuilder() {}
7575

@@ -126,9 +126,10 @@ public ReactInstanceManagerBuilder setJSBundleLoader(JSBundleLoader jsBundleLoad
126126
* Sets the JS Engine to load as either Hermes or JSC. If not set, the default is JSC with a
127127
* Hermes fallback.
128128
*/
129-
private void setJSEngineResolutionAlgorithm(
129+
public ReactInstanceManagerBuilder setJSEngineResolutionAlgorithm(
130130
@Nullable JSEngineResolutionAlgorithm jsEngineResolutionAlgorithm) {
131-
this.jsEngineResolutionAlgorithm = jsEngineResolutionAlgorithm;
131+
mJSEngineResolutionAlgorithm = jsEngineResolutionAlgorithm;
132+
return this;
132133
}
133134

134135
/**
@@ -362,7 +363,7 @@ private JavaScriptExecutorFactory getDefaultJSExecutorFactory(
362363

363364
// if nothing is specified, use old loading method
364365
// else load the required engine
365-
if (jsEngineResolutionAlgorithm == null) {
366+
if (mJSEngineResolutionAlgorithm == null) {
366367
FLog.w(
367368
TAG,
368369
"You're not setting the JS Engine Resolution Algorithm. "
@@ -379,7 +380,7 @@ private JavaScriptExecutorFactory getDefaultJSExecutorFactory(
379380
HermesExecutor.loadLibrary();
380381
return new HermesExecutorFactory();
381382
}
382-
} else if (jsEngineResolutionAlgorithm == JSEngineResolutionAlgorithm.HERMES) {
383+
} else if (mJSEngineResolutionAlgorithm == JSEngineResolutionAlgorithm.HERMES) {
383384
HermesExecutor.loadLibrary();
384385
return new HermesExecutorFactory();
385386
} else {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ protected ReactInstanceManager createReactInstanceManager() {
8181
.setJSIModulesPackage(getJSIModulePackage())
8282
.setInitialLifecycleState(LifecycleState.BEFORE_CREATE)
8383
.setReactPackageTurboModuleManagerDelegateBuilder(
84-
getReactPackageTurboModuleManagerDelegateBuilder());
84+
getReactPackageTurboModuleManagerDelegateBuilder())
85+
.setJSEngineResolutionAlgorithm(getJSEngineResolutionAlgorithm());
8586

8687
for (ReactPackage reactPackage : getPackages()) {
8788
builder.addPackage(reactPackage);

0 commit comments

Comments
 (0)