getx icon indicating copy to clipboard operation
getx copied to clipboard

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

Open rmControls opened this issue 3 years ago • 9 comments

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...

rmControls avatar Sep 06 '21 04:09 rmControls

Yes. Same issue here.

saravananmnm avatar Sep 06 '21 10:09 saravananmnm

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

rmControls avatar Sep 07 '21 13:09 rmControls

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

saravananmnm avatar Sep 13 '21 08:09 saravananmnm

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.

MrCsabaToth avatar Sep 26 '21 01:09 MrCsabaToth

@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...

rmControls avatar Oct 12 '21 15:10 rmControls

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/

MrCsabaToth avatar Oct 13 '21 07:10 MrCsabaToth

Have same issue. Any solution for this @jonataslaw?

Hetal9Brainz avatar Jan 31 '24 12:01 Hetal9Brainz

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

disonwei avatar Feb 03 '24 08:02 disonwei

Same issue, haizzz

deverlex avatar Mar 04 '24 14:03 deverlex