question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues after android system closes application

See original GitHub issue

Hi Chris! This is an amazing library and has helped considerably with a RN project I am working on. Thank you with putting it together and also for your contribution to other cross-platform development ecosystems!

I’ve been tracking a bug for several weeks and was hoping you could shed some insight on how to address an issue that I’m encountering. Also, I think this may apply to the native implementation, so I’m happy to re-post in https://github.com/transistorsoft/transistor-background-fetch if needed.

==========

Plugin version: 2.4.5 Platform: Android OS version: 9.0, 8.0, 7.1 Device manufacturer / model: Essential Phone, HTC 10, Nextbit Robin React Native version (react-native -v): 0.57.8 Plugin config: minimumFetchInterval: 15, stopOnTerminate: false, startOnBoot: true, forceReload: true,

Expected Behavior

If app is killed by android system. React-native-background-fetch should restart app (and MainActivity) just like when user swipes out application.

Actual Behavior

When the app is killed by system, background fetch still runs at fixed interval (and logs “Background Fetch event received”), but app is assigned a new PID when it is relaunched by background-fetch, and doesn’t seem to initialize RN app properly since no JS will run, and the background fetch seems to time out printing “onStopJob” after a while.

IE: background fetch stops running properly after app is killed by system and after killed notifications/actions won’t work until user opens app manually which triggers a reset.

After this ‘crash’, the next time I bring the app to foreground, it initializes, then minimizes immediately as if being force reloaded by react-native-background-fetch, but it doesn’t print “MainActivity is inactive” and “Forcing MainActivity reload” like it does when app is reset in background after being swiped out by user. Ideally, it would be able to restart the MainActivity in the same way without me clicking on the app.

It starts working again properly after bringing app to foreground manually,

Steps to Reproduce

  1. Wait all day w/o bringing app to foreground until app is killed by system and I stop receiving the notifications that should be scheduled by my background task
  2. Inconsistent behavior but seems to be an issue for some phones more than others (some phone 1-2 times per day) some phones can’t reproduce.

Context

I’m trying to implement background tasks that persist after app is killed by system

Debug logs

Normal logs:

03-25 13:29:32.841 15313 15313 D TSBackgroundFetch: - Background Fetch event received 03-25 13:29:32.841 15313 15332 D ReactNativeJS:: - a bunch of stuff I’m printing 03-25 13:29:32.841 15313 15313 D TSBackgroundFetch: - finish 03-25 13:29:32.841 15313 15313 D TSBackgroundFetch: - jobFinished

After being closed by system (assigns new PID):

03-27 09:52:19.314 17419 17419 D TSBackgroundFetch: - Background Fetch event received 03-27 09:52:24.203 17419 17419 D TSBackgroundFetch: - onStopJob 03-27 09:52:54.841 17419 17419 D TSBackgroundFetch: - Background Fetch event received 03-27 10:02:54.862 17419 17419 D TSBackgroundFetch: - onStopJob 03-27 10:03:59.864 17419 17419 D TSBackgroundFetch: - Background Fetch event received 03-27 10:07:54.836 17419 17419 D TSBackgroundFetch: - onStopJob 03-27 10:10:39.369 17419 17419 D TSBackgroundFetch: - Background Fetch event received 03-27 10:16:44.769 17419 17419 D TSBackgroundFetch: - onStopJob 03-27 10:20:44.823 17419 17419 D TSBackgroundFetch: - Background Fetch event received

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
christocracycommented, May 29, 2019

@mason-parachute I was doing some work today on transistor-background-fetch, #154, #157. I’ll be having at look at your PR #4 there, tomorrow.

1reaction
mason-parachutecommented, May 29, 2019

It doesn’t work with current version of master, only my fork. I’m using the following config:

minimumFetchInterval: 15, stopOnTerminate: false, startOnBoot: true, enableHeadless: true

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Stop Apps From Crashing on Android - AVG
When apps keep closing, sometimes uninstalling and reinstalling the app can fix the problem. Your app might be out of date or have...
Read more >
Why Do My Apps Keep Crashing on Android? - Avast
Apps on Android can crash because of low storage space, too many apps running simultaneously, a weak internet connection, or not having the ......
Read more >
Why do my apps keep crashing on Android, How to fix it
How to fix apps that keep crashing on Android · 1. Force stop the app · 2. Restart the device · 3 ....
Read more >
Why are my Android phone apps crashing or closing & how to ...
Find out why your Samsung Galaxy Android phone apps keep crashing, closing, freezing or stop working. Fix the issue with our guide and...
Read more >
11 Quick Ways to Fix Apps Keep Crashing on Android - iMobie
Go to “Settings” > Apps > Find the app that keeps crashing. · Go to Settings > “Apps” or “Application manager” > Choose...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found