Android app is crashing (in background) when headlessJS job is fired in release variant
See original GitHub issueYour Environment
- Plugin version: 2.6.0
- Platform: Android
- OS version: 8.0.0
- Device manufacturer / model: Samsung Galaxy S7
- React Native version: 0.59.8
- Plugin config
minimumFetchInterval: 15, stopOnTerminate: false, startOnBoot: true, enableHeadless: true,
Expected Behavior
Android app shouldn’t crash whenever Headless JS Task is fired.
Actual Behavior
Android app is crashing in release build whenever Headless JS Task is fired.
Steps to Reproduce
- Configure bgfetch
- Instal release variant of android app
- Run
adb shell cmd jobscheduler run -f com.xxx 999
- App is crashing
Code
componentDidMount() {
setUpBackgroundTask()
BackgroundFetch.registerHeadlessTask(setUpBackgroundTask)
}
const setUpBackgroundTask = () => {
BackgroundFetch.configure(
{
minimumFetchInterval: 15,
stopOnTerminate: false,
startOnBoot: true,
enableHeadless: true,
},
() => {
_checkTerminatingAndTerminate()
}
)
BackgroundFetch.status(status => {
switch (status) {
case BackgroundFetch.STATUS_RESTRICTED:
showAlertMessage(
determineErrorMessage(
{
response: {
err_code: "ERROR_BACKGROUND_APP_REFRESH_RESTRICTED",
},
},
() => {
store.dispatch(setDrivingModeOff())
}
)
)
break
case BackgroundFetch.STATUS_DENIED:
showAlertMessage(
determineErrorMessage(
{
response: {
err_code: "ERROR_BACKGROUND_APP_REFRESH_DENIED",
},
},
() => {
store.dispatch(setDrivingModeOff())
}
)
)
break
}
})
}
Debug logs
07-23 14:03:00.277 5812 5812 D TSBackgroundFetch: HeadlessJobService onStartJob
07-23 14:03:00.351 5812 5812 D ReactNative: ReactInstanceManager.createReactContextInBackground()
07-23 14:03:00.351 5812 5812 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundInner()
07-23 14:03:00.351 5812 5812 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundFromBundleLoader()
07-23 14:03:00.351 5812 5812 D ReactNative: ReactInstanceManager.recreateReactContextInBackground()
07-23 14:03:00.351 5812 5812 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
07-23 14:03:00.362 5812 5834 D ReactNative: ReactInstanceManager.createReactContext()
07-23 14:03:00.441 5812 5834 D ReactNative: Initializing React Xplat Bridge.
07-23 14:03:00.446 5812 5834 D ReactNative: Initializing React Xplat Bridge before initializeBridge
07-23 14:03:00.461 5812 5834 D ReactNative: Initializing React Xplat Bridge after initializeBridge
07-23 14:03:00.461 5812 5834 D ReactNative: CatalystInstanceImpl.runJSBundle()
07-23 14:03:00.479 5812 5839 D ReactNative: ReactInstanceManager.setupReactContext()
07-23 14:03:00.479 5812 5839 D ReactNative: CatalystInstanceImpl.initialize()
07-23 14:03:00.985 5812 5812 D TSBackgroundFetch: onHeadlessJsTaskStart: 1
Issue Analytics
- State:
- Created 4 years ago
- Comments:18 (10 by maintainers)
Top Results From Across the Web
Crashes | Android Developers
An Android app crashes whenever there's an unexpected exit caused by an unhandled exception or signal. An app that is written using Java...
Read more >Release app crashes instantly when run. Debug version is ...
I can run my app fine on my phone while debugging but by running npx react-native run-android --variant=release or making a release apk...
Read more >How to Fix Crashing Apps on an iPhone or Android?
Update App To The Last Version, The App Crash Fixer. Sometimes app-crashing is not caused by your phone, but rather the app itself....
Read more >Headless JS - React Native
Headless JS is a way to run tasks in JavaScript while your app is in the background. It can be used, for example,...
Read more >Troubleshooting build errors and crashes - Expo Documentation
For example, you might see something like this on your Android builds: Terminal ... Locally compile and run the Android app in release...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Of course.
Thanks @christocracy!