Issue
we're currently having an issue where we'll end up getting a TransactionTooLargeException when application is paused or when calling other activities (i.e. camera activity). The application is simply a wrapper for a web application using WebView and exposes BLE tag and a barcode reader through a javascript interface.
After utilizing the TooLargeTool library we were able to get some logcat messages and the culprit seems to be WEBVIEW_CHROMIUM_STATE. Below is 3 captures during different app pauses and it shows webview's state seems to balloon over time, though sometimes it goes down as well.
* android:state = 0.0 KB
* android:viewHierarchyState = 0.4 KB
* @android:autofillResetNeeded = 0.1 KB
* WEBVIEW_CHROMIUM_STATE = 61.8 KB
* android:lastAutofillId = 0.1 KB
* android:fragments = 0.4 KB
* android:sessionId = 0.1 KB
* android:state = 0.0 KB
* android:viewHierarchyState = 0.4 KB
* @android:autofillResetNeeded = 0.1 KB
* WEBVIEW_CHROMIUM_STATE = 171.0 KB
* android:lastAutofillId = 0.1 KB
* android:fragments = 0.4 KB
* android:sessionId = 0.1 KB
* android:state = 0.0 KB
* android:viewHierarchyState = 0.4 KB
* @android:autofillResetNeeded = 0.1 KB
* WEBVIEW_CHROMIUM_STATE = 252.3 KB
* android:lastAutofillId = 0.1 KB
* android:fragments = 0.4 KB
* android:sessionId = 0.1 KB
On older tablets (Samsung Android 7 and 8) it seems to occur around the 550k mark. On newer tablers (also Samsung) it seems to occur around the 1MB mark.
We don't have any control over the web application (which maintains session state), so we're trying to fix this on the tablet. Does anyone know a solution to prevent the WebView's state from ballooning, or other solution (maybe stream the state to storage and only store a handle to the file) that maintains compatibility with the session based web app?
Cheers.
Mark.
Solution
This has ended up being a non-issue. After reviewing the saveState function on the WebView it appears the majority of the use-case we would use it for no longer applies.
https://developer.android.com/reference/android/webkit/WebView#saveState(android.os.Bundle)
"Please note that this method no longer stores the display data for this WebView. The previous behavior could potentially leak files if restoreState(Bundle) was never called."
saveState seems to just save WebHistoryItem objects in a WebBackForwardList so as the user spends longer in the app navigating pages the state gets larger and larger.
Since the web app doesn't use back/forward I don't consider this a negative. Have tested completely removing the saveState and as long as the app isn't destroyed by Android the WebView is still in the state it was on resume, i.e. the app being paused by the camera call, or switching to another app, the webview is still fine.
Answered By - Mark McCabe
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.