Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autosave not persistant #234

Open
smellymoo opened this issue Nov 22, 2022 · 16 comments
Open

autosave not persistant #234

smellymoo opened this issue Nov 22, 2022 · 16 comments
Labels

Comments

@smellymoo
Copy link

When the app is closed properly, game progress is lost. That seems like a serious problem.

@smellymoo
Copy link
Author

is this project still alive? I can probably help you debug the problem, I am a developer (got a 50+ million download app).

@ildar
Copy link

ildar commented Nov 28, 2022 via email

@ligi
Copy link
Owner

ligi commented Nov 28, 2022

yea - also need to cut a new release soon

@ildar
Copy link

ildar commented Nov 28, 2022 via email

@smellymoo
Copy link
Author

just had a quick dig, I think it might be that you only have onpause, and android can skip onpause in certain cases?

@ligi
Copy link
Owner

ligi commented Apr 10, 2023

OnPause should actually never be skipped:

image

@smellymoo
Copy link
Author

smellymoo commented Apr 11, 2023

Lol. Oh I remember being your level of optimistic about android, that passed about 5 years ago...

Read the android docs and you will quickly discover that it's all bs, they have fat warnings everywhere saying that they may not happen.

The android life cycle is a great idea, but they didn't implement it probably. Now it's garbage. Basically I have seen most parts skipped, or called twice, or called out of order (when there is more than one activity) 🤦

There are different ways to deal with this, mine was to not trust all the life cycle calls, and feed them into my own generic handler of state, then that keeps track of It's own state and calls my own start or stop functions. This then debounces and allows android to forget to call things.

At the very minimum you need to combine onPause and onStop (and maybe onSaveInstanceState() ) to get anything reliable.

@smellymoo
Copy link
Author

I call your photo and raise you...

Screenshot_20230411_080106

@smellymoo
Copy link
Author

The worst of it is:

onPause() may be called unexpectedly if the activity is partially obscured by a system dialog or if the system needs to reclaim resources.

onResume() may be called unexpectedly if the activity was partially obscured by a system dialog or if the system needed to reclaim resources.

onSaveInstanceState() may not be called if the activity is destroyed unexpectedly, such as during a low-memory situation or a process death.

onStop() may be called unexpectedly if the system needs to reclaim resources, or if the activity is partially obscured by a system dialog.

@ligi
Copy link
Owner

ligi commented Apr 11, 2023

can you point me to where in the docs it states onPause might not be called?

@smellymoo
Copy link
Author

Screenshot_20230411_132947_Firefox.jpg

I'm on my phone right now. That is one example. But honestly, if you don't want to fix it, that's on you. Done my part.

@smellymoo
Copy link
Author

I am sorry. I was having a bad day and you were looking at the finger pointing rather than what it was pointing at.

Maybe just call it a feature not a bug? when you put your phone down it's non-deterministic if you still have your game when you go back, gives you a little gambling kick... also if you are losing the game, then it's like "oh shit, it cleared itself, oh well, shall we start again?"

@ligi
Copy link
Owner

ligi commented Apr 19, 2023

Thanks - no I want to fix it - guess I just do the saving after each move then - I think this should solve the problem.

@ligi ligi added the bug label Apr 19, 2023
@smellymoo
Copy link
Author

that is an easy and robust solution.

Other ideas would be:

  • running a background service (pain in the bum).
  • funnelling all of the possible ones (onPause, onStop, and onSaveInstanceState) into save, with debounce logic.
  • timer based pause (this would be an optimization on top of your solution)
  • ???

@37elivan73
Copy link

Hi everyone, I'm still here, an apology for closing this project. Stop, I'll restart it. If it's still not there, let me know or if you can restart it, go ahead. On the other hand, I thank everyone for their support.

1 similar comment
@37elivan73
Copy link

Hi everyone, I'm still here, an apology for closing this project. Stop, I'll restart it. If it's still not there, let me know or if you can restart it, go ahead. On the other hand, I thank everyone for their support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants