jonataslaw / getx

Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.
MIT License
10.24k stars 1.61k forks source link

not able to find GetxService when app goes to background.... #1837

Open rmControls opened 3 years ago

rmControls commented 3 years ago

getting error message GetxService not found when app in to background ....

you get following error message when app in background... it works perfectly when app in Foreground. "MessageService" not found. You need to call "Get.put(MessageService())" or "Get.lazyPut(()=>MessageService())"

Please check...

saravananmnm commented 3 years ago

Yes. Same issue here.

rmControls commented 3 years ago

@jonataslaw can you please help us with this issue...??

saravananmnm commented 3 years ago

@jonataslaw @jasonlaw @lsm Any workarounds for this.?

MrCsabaToth commented 2 years ago

So I was running into a service disappearing in my app which was not disappearing before. The Smart Management decided to ditch that service. I have a feeling that maybe it has to do something with the fact that I started to obey Android Studio linting suggestions and applied a lot of const keywords and alike and maybe that showed some memory objects more discardable than before, but that is just really a guess.

The bottom line is - try to tell Get to keep your service in the memory by utilizing the permanent named parameter of put, like so: Get.put(MessageService(), permanent: true). Of course this has some consequences such as you need to take control when you want to discard that service manually, so you have to command the lifecycle of the service on your own.

rmControls commented 2 years ago

@MrCsabaToth, this issue is different... the GetXService is not available when app goes to background....

@jonataslaw @jasonlaw @lsm please suggest any temporary solution for this...

MrCsabaToth commented 2 years ago

the GetXService is not available when app goes to background....

From your issue opening description it looks like that MessageService is not available. What is GetXService? We need some code, can you point to a repository? Or some more complete error message. From what you quoted originally it seems like to me that either GetX's or Flutter memory management cleans / garbage collects the MessageService.

Regarding background: I had trouble with background functionality before (not GetX, but bluetooth data stream coming in) and such issues can be even hard to solve if someone is on a native Android playground. Flutter just adds another layer of abstraction of over that. So looking at the big picture I'd consider exploring background tasks + Flutter such as https://flutter.dev/docs/development/packages-and-plugins/background-processes or https://pub.dev/packages/workmanager

Also: talking about layer of abstractions background tasks' topic opens another can of worms: https://dontkillmyapp.com/

Hetal9Brainz commented 7 months ago

Have same issue. Any solution for this @jonataslaw?

disonwei commented 7 months ago

https://github.com/jonataslaw/getx/issues/3029 The same issue

deverlex commented 6 months ago

Same issue, haizzz