Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure SoLoader is initialized before attempting to load jscexecutor … #26343

Closed

Conversation

petterh
Copy link
Contributor

@petterh petterh commented Sep 5, 2019

Summary

This change fixes the issue "ReactInstanceManagerBuilder.build fails unless SoLoader.init has been called" on Android.

The ReactInstanceManager constructor calls initializeSoLoaderIfNecessary, so the intent is clearly that things should work without an explicit call to SoLoader.init on the part of the application.

However, with the introduction of Hermes, we have ReactInstanceManagerBuilder.getDefaultJSExecutorFactory, which gets called before the ReactInstanceManager constructor. It attempts this:

SoLoader.loadLibrary("jscexecutor");

This fails with the following stack trace:

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.facebook.react.uiapp/com.facebook.react.uiapp.RNTesterActivity}: java.lang.RuntimeException: SoLoader.init() not yet called
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
    at android.app.ActivityThread.-wrap11(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6944)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
 Caused by: java.lang.RuntimeException: SoLoader.init() not yet called
    at com.facebook.soloader.SoLoader.assertInitialized(SoLoader.java:781)
    at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:505)
    at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
    at com.facebook.react.ReactInstanceManagerBuilder.getDefaultJSExecutorFactory(ReactInstanceManagerBuilder.java:291)
    at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:266)
    at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:86)
    at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:38)
    at com.facebook.react.ReactDelegate.loadApp(ReactDelegate.java:103)
    at com.facebook.react.ReactActivityDelegate.loadApp(ReactActivityDelegate.java:83)
    at com.facebook.react.ReactActivityDelegate.onCreate(ReactActivityDelegate.java:78)
    at com.facebook.react.uiapp.RNTesterActivity$RNTesterActivityDelegate.onCreate(RNTesterActivity.java:40)
    at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:44)
    at android.app.Activity.performCreate(Activity.java:7183)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032) 
    at android.app.ActivityThread.-wrap11(Unknown Source:0) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) 
    at android.os.Handler.dispatchMessage(Handler.java:105) 
    at android.os.Looper.loop(Looper.java:164) 
    at android.app.ActivityThread.main(ActivityThread.java:6944) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) 

Changelog

[Android] [Fixed] - Don't crash ReactInstanceManagerBuilder.build even if SoLoader has not been explicitly initialized

Test Plan

To demonstrate the defect, remove the call to SoLoader.init from RNTester.onCreate and run the app.

To demonstrate the fix, apply this PR, which does in fact also remove the call to SoLoader.init

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Microsoft Partner: Microsoft Partner labels Sep 5, 2019
@react-native-bot react-native-bot added Bug Platform: Android Android applications. labels Sep 5, 2019
Copy link
Contributor

@mdvacca mdvacca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdvacca is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @petterh in 60e00d9.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Sep 6, 2019
@petterh petterh deleted the petterh/dont-require-soloader-init branch September 6, 2019 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. p: Microsoft Partner: Microsoft Partner Platform: Android Android applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants