Skip to content

Commit

Permalink
Fix crash in HeadlessAppLoader after the activity is killed
Browse files Browse the repository at this point in the history
devSupportManager can be null. This is evident both from my experience and from similar code in:
https://github.com/expo/expo/blob/0ec9e78c4e4ff0656eaa861b50618a80b8650952/android/expoview/src/main/java/host/exp/exponent/experience/ReactNativeActivity.java#L293

This crash was preventing background fetch from working, as the app was crashing when trying to restart.
This is probably related to the many background task issues in the issue tracker such as: expo#3503, expo#3582, expo#4860 and
potentially others.

I have not been able to test it locally (no idea how to build expo kit, and wasn't able to get help on the Slack), though
the code seems right, and it's a trivial change.
  • Loading branch information
tasn committed Jan 28, 2020
1 parent 9b7cd4e commit a699772
Showing 1 changed file with 6 additions and 3 deletions.
Expand Up @@ -317,9 +317,12 @@ private RNObject startReactInstance(final Exponent.StartReactInstanceDelegate de
}

RNObject reactInstanceManager = builder.callRecursive("build");
RNObject devSettings = reactInstanceManager.callRecursive("getDevSupportManager").callRecursive("getDevSettings");
if (devSettings != null) {
devSettings.setField("exponentActivityId", mActivityId);
RNObject devSupportManager = mReactInstanceManager.callRecursive("getDevSupportManager");
if (devSupportManager != null) {
RNObject devSettings = devSupportManager.callRecursive("getDevSettings");
if (devSettings != null) {
devSettings.setField("exponentActivityId", mActivityId);
}
}

reactInstanceManager.call("createReactContextInBackground");
Expand Down

0 comments on commit a699772

Please sign in to comment.