feat(webview): add release() helper that detaches and destroys cleanly (#562)#808
Open
jim-daf wants to merge 2 commits intoAwful:developfrom
Open
feat(webview): add release() helper that detaches and destroys cleanly (#562)#808jim-daf wants to merge 2 commits intoAwful:developfrom
jim-daf wants to merge 2 commits intoAwful:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an explicit teardown helper to AwfulWebView intended to prevent long-session WebView/Chromium renderer leaks by performing a more thorough cleanup sequence before destroy().
Changes:
- Add
AwfulWebView.release()helper to clear JS interface, navigate toabout:blank, clear history, detach from parent, and destroy the WebView.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+134
to
+136
| ViewGroup parent = (ViewGroup) getParent(); | ||
| if (parent != null) { | ||
| parent.removeView(this); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #562.
The StackOverflow answer linked in the issue boils down to: detach the WebView from its parent and call
destroy()so Chromium can release its renderer process. Just letting the activity die leaks the surface and, on long sessions, eventually OOMs.This PR adds an explicit
release()helper onAwfulWebViewthat does the full cleanup dance (clear the JS interface so it does not retain the activity, navigate to about:blank, drop history, detach from parent, thendestroy()). Hosting fragments and activities can call it from their ownonDestroy/onDestroyViewwhenever they are sure they are done with the view.Wiring the call sites is left out on purpose. The fragments that own a WebView each have their own teardown path, and rolling them all in one PR would balloon the diff.