Skip to content

Commit

Permalink
Make setJSEngineResolutionAlgorithm a public method (#36715)
Browse files Browse the repository at this point in the history
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: #36715

Reviewed By: cortinico

Differential Revision: D44535444

Pulled By: javache

fbshipit-source-id: ae91e50de10c993c80ed4bba6f2fece64af178c4
  • Loading branch information
SparshaSaha authored and facebook-github-bot committed Mar 30, 2023
1 parent e5dd9cd commit cb376dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class ReactInstanceManagerBuilder {
private @Nullable ReactPackageTurboModuleManagerDelegate.Builder mTMMDelegateBuilder;
private @Nullable SurfaceDelegateFactory mSurfaceDelegateFactory;
private @Nullable DevLoadingViewManager mDevLoadingViewManager;
private JSEngineResolutionAlgorithm jsEngineResolutionAlgorithm = null;
private @Nullable JSEngineResolutionAlgorithm mJSEngineResolutionAlgorithm = null;

/* package protected */ ReactInstanceManagerBuilder() {}

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

/**
Expand Down Expand Up @@ -362,7 +363,7 @@ private JavaScriptExecutorFactory getDefaultJSExecutorFactory(

// if nothing is specified, use old loading method
// else load the required engine
if (jsEngineResolutionAlgorithm == null) {
if (mJSEngineResolutionAlgorithm == null) {
FLog.w(
TAG,
"You're not setting the JS Engine Resolution Algorithm. "
Expand All @@ -379,7 +380,7 @@ private JavaScriptExecutorFactory getDefaultJSExecutorFactory(
HermesExecutor.loadLibrary();
return new HermesExecutorFactory();
}
} else if (jsEngineResolutionAlgorithm == JSEngineResolutionAlgorithm.HERMES) {
} else if (mJSEngineResolutionAlgorithm == JSEngineResolutionAlgorithm.HERMES) {
HermesExecutor.loadLibrary();
return new HermesExecutorFactory();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ protected ReactInstanceManager createReactInstanceManager() {
.setJSIModulesPackage(getJSIModulePackage())
.setInitialLifecycleState(LifecycleState.BEFORE_CREATE)
.setReactPackageTurboModuleManagerDelegateBuilder(
getReactPackageTurboModuleManagerDelegateBuilder());
getReactPackageTurboModuleManagerDelegateBuilder())
.setJSEngineResolutionAlgorithm(getJSEngineResolutionAlgorithm());

for (ReactPackage reactPackage : getPackages()) {
builder.addPackage(reactPackage);
Expand Down

0 comments on commit cb376dd

Please sign in to comment.