flutter_background icon indicating copy to clipboard operation
flutter_background copied to clipboard

[BUG] after running for some hours app restarts and the notification text changes to default.

Open chocovish opened this issue 4 years ago • 9 comments

This plugin works quite well except for the first time crash while granting permission. what I noticed that if I run the app for few hours like 8-9hours it restarts autoomatically (as I can see the "time since" thing in notification changes). and the notification title and description text switch backs to default (keeps the flutter app running in the background). attaching screenshot.

image

chocovish avatar Dec 30 '20 19:12 chocovish

Thank you very much for the bug report! What device are you using? On my Pixel 5 I didn't observe this behavior yet, but maybe some OEMs kill long running apps after a while.

JulianAssmann avatar Dec 31 '20 19:12 JulianAssmann

Good and excellent library. The same thing happened to me on a galaxy s9, the service only lasted 15 minutes, it only happened once for now, I don't know what the problem will be, maybe android kills the service, any other reason for this bug?

daurin-oshin avatar Jan 12 '21 11:01 daurin-oshin

Interesting... Do you have any console logs available from when it resets/cancels the foreground service? I will try and investigate, but so far I haven't been able to reproduce the problem on my own device :(

JulianAssmann avatar Jan 13 '21 21:01 JulianAssmann

Excellent library, thank you for creating this, Julian!

For what it's worth, I am also experiencing this on a Samsung device. Might be unrelated, but Crashlytics also reported crashes at the same time. Let me know if you'd like me to create a separate issue for this instead (crash is coming from Samsung and Pixel devices, which covers 100% of the install base of our app)

Caused by java.lang.IllegalArgumentException: Parameter specified as non-null is null: method l.v.d.j.b, parameter intent
       at de.julianassmann.flutter_background.IsolateHolderService.onStartCommand(:2)
       at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4723)
       at android.app.ActivityThread.access$2000(ActivityThread.java:301)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2168)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8456)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:596)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

akospwc avatar Mar 22 '21 13:03 akospwc

Thank you very much for the information, I will look into it when I have some time to spare :)

JulianAssmann avatar Mar 27 '21 16:03 JulianAssmann

I have the same problem. Excellent library! Thanks!

ViniciusDiasSilva avatar Mar 30 '21 17:03 ViniciusDiasSilva

Thank you for your kind words and the comment. Do you have the same stack trace as @akospwc or some other error?

JulianAssmann avatar Mar 31 '21 14:03 JulianAssmann

I believe what's happening here is that the app crashes and the OS automatically restarts the service. In this case initialize() is not getting called in time, meaning we are reverting to the default text.

I was able to reproduce this behavior with the example app:

  • $ cd example
  • $ flutter run
  • start the demo by pressing Connect
  • press 'q' on the console to exit the app

The notification disappears and then reappears in a few seconds with the default text.

I fixed this by storing the notification's configuration in shared preferences and then reloading them before use. @JulianAssmann would you mind taking a look?

https://github.com/akospwc/flutter_background/commit/b942e4a88b9034260f62ac63d882017102a26841

akospwc avatar Jul 08 '21 21:07 akospwc

Does hits merged?

luohao123 avatar May 11 '23 16:05 luohao123