Pause-resume issues / Move detach to onDestroy? #454
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been coming across a few niggly pause/resume issues (listed below).
What do you think about moving the getTileProvider().detach() from onPause to onDestroy? I'm worried about memory leaks if I do this? I tried running it with LeakCanary but it didn't show any memory leak after I stopped the app. On the other hand it also didn't show a memory leak when I took the detach out altogether so I'm confused there...
The code would need more work around the onResume / onPause but first I just wanted to ask what you thought about the general principle of moving the detach to onDestroy?
Here are some of the issues:
Location Editor: map is lost when resuming after pausing, e.g. if permission request box comes up or if you go to the Home screen
If in Itinerary or Blog when pausing, screen goes to journey planner (or most recent ?resumable? fragment) when resuming, rather than back to Itinerary or Blog.
If Find a Place marker is showing when pausing, it would disappear when resuming except that I have put in a workaround to store it. This means is stays there even if app destroyed – not so good. I could refine the workaround further but I'd prefer to improve the pause/resume and get rid of this workaround.
If POI bubble is displayed on journey planner, the bubble disappears when resuming. It also disappears if you go to another screen (e.g. Itinerary) and back.
(I think waymarkers are stored so that they remain if app paused or destroyed. I think that's good to keep them even when app destroyed.)
When an item is selected from the Navigation Drawer (top left menu), a new instance of the fragment is created, meaning again that current state is lost (e.g. going from journey planner to Itinerary and back will mean that POI bubble disappears).
If the permission request box comes up this also pauses the app. I would like the app to continue straight to the requested action if permission is granted but this is made more difficult by the fact that the fragment is destroyed and re-created when the app resumes.