Save and restore the state if the app process is killed in the background
The tabs and the state of the WebViews could be stored in the bundle and reapplied when the app is restarted.
It might or might not be possible to save the WebView histories, because I'm not sure there is a way to recreate them based on data that can fit in a bundle.
Note that this is simply the movement of information that is in one part of RAM to a different part of RAM so that it persists if Android's memory management system reclaims the majority of Privacy Browser's RAM usage while it is not in the foreground. It will not create any permanent storage on the flash and will not persist data if Privacy Browser is closed or if the device is restarted. Specifically, if the app ever reaches the `onDestroy()` stage the data will be lost.
Updated by Soren Stoutner over 2 years ago
A little more background for those who may not be aware of how Android handles memory (very poorly is the short answer), when an app is displayed on the screen it is in the foreground. If the screen is turned off or a different app is displayed on the screen, then the app is moved to the background. As described in the Android lifecycle link above, this will cause `onPause()` and `onStop()` to be called. When an app is in the stopped state, all of the information about what the app is currently doing is stored in RAM. However, if Android decides it needs this RAM it can kill the app process. This destroys all the information in RAM except for a little bit that is stored in a Bundle (https://developer.android.com/reference/android/os/Bundle). Bundles do not allow the storage of most information as it is used by an app when it is running, but they do allow extracting important pieces of information and storing them as numbers or strings. If an app process has been killed, when it is brought back to the foreground it is launched again beginning with `onCreate()`. This lays out the entire app from scratch, but also presents the bundle, allowing the app to recreate the interface as it existed before.
Currently, Privacy Browser does not store any information in the bundle, meaning that if the app process is killed and the user then brings it back to the foreground, any open tabs will be lost along with all of their associated information. In this scenario, the intent that originally started the app will be used to load one tab (meaning that sometimes a user will see a tab they haven't had open in a while loaded). The idea of this feature request is to store the state of each tab in the bundle and restore their state if the app process is killed. Because of the complexity of the tabs, this is a more difficult process than might be readily apparent. Also, as noted above, some information might be hard to store in a bundle. But I would like to save and restore as much as possible.
Updated by Soren Stoutner over 1 year ago
- Status changed from New to Closed