Thunder re-loads in background too often.
Bug Description
If I go back and forth between Fennec and Thunder, I will often find that Thunder reloads in the background, and I lose posts I was creating.
Expected Behaviour
Thunder should be able to remain open.
Steps to Reproduce
- Open an article you wish to share in fennec
- Open thunder
- Open menu and choose a community
- Tap "+" to create a new post
- Use app switcher to switch to fennec, copy article title
- Switch back to thunder via app switcher (problem might occur at this point)
- Paste title in title box
- Switch to fennec with app switcher, open menu, share, copy the url
- Switch to thunder via app switcher (problem may occur here as well)
Additional Context
This bug does not occur all the time, but it occurs often enough to be quite irritating.
App Version
<= 0.6.0-1
Device
OnePlus Nord N200
OS
LineageOS 21 (Android 14)
This problem generally occurs when Android runs out of memory and tries to free up memory by suspending background apps.
For devs: Flutter has the ability to restore state when the OS kills the app (when freeing up memory), however, we don't currently use that feature. Implementing this will take a bit of effort but we could possibly break this up into stages:
- Implement restorable states for routing (e.g., opening the app would restore back the navigation that we were in previously). Initial work is started with #1613.
- Implement restorable states for inputs (e.g., text inputs, dropdowns, toggles, etc)
- Implement restorable states for more complex states (bloc related data such as feed, posts, comments, etc). This part will likely be the most time-consuming/complex implementation from this list
- Implement restorable states for scroll position (e.g., keep the specific scroll position within the feed)
See, that's what's weird though, is that my phone has a decent amount of RAM, and other apps do not do this, and I don't have a bunch of other apps open in the background at all times either.
I can also still reproduce this easily enough on a 8 GB smartphone on latest release (0.6.1).