Skip to content

Fix WebView Memory Leak in GutenbergView#156

Merged
oguzkocer merged 2 commits intotrunkfrom
followup-to-allow-multiple-sites-in-android-demo-app
Jul 17, 2025
Merged

Fix WebView Memory Leak in GutenbergView#156
oguzkocer merged 2 commits intotrunkfrom
followup-to-allow-multiple-sites-in-android-demo-app

Conversation

@oguzkocer
Copy link
Contributor

Follow-up to #155 that addresses WebView memory leaks in GutenbergView.

Changes

  • Fix WebView cleanup: Added this.destroy() call to GutenbergView.onDetachedFromWindow() to properly dispose of WebViews when detached from window hierarchy.
  • Remove unnecessary namespace: Removed setSiteApiNamespace(arrayOf("wp/v2")) call as it's only needed for WPCOM sites using the WPCOM API

Testing

  1. Open Android demo app
  2. Tap "Bundled Editor" to open the editor
  3. Open Chrome DevTools and navigate to chrome://inspect
  4. Verify WebView appears in inspector while editor is open
  5. Close editor to return to site picker
  6. Verify WebView disappears from Chrome inspector
  7. Open editor again
  8. Verify new WebView appears in inspector

Before this fix, WebViews would accumulate in the inspector after closing the editor.

…dow()

WebViews were lingering in Chrome inspector after closing the editor because GutenbergView.onDetachedFromWindow() cleaned up listeners but didn't call WebView.destroy(). Adding this.destroy() ensures WebViews are properly disposed of when detached from the window hierarchy.
@oguzkocer oguzkocer requested a review from dcalhoun July 17, 2025 20:29
@oguzkocer oguzkocer changed the title Fix WebView Memory Leak in Android Demo Fix WebView Memory Leak in GutenbergView Jul 17, 2025
@oguzkocer oguzkocer changed the title Fix WebView Memory Leak in GutenbergView Fix WebView Memory Leak in GutenbergView Jul 17, 2025
@oguzkocer oguzkocer enabled auto-merge (squash) July 17, 2025 20:29
Copy link
Member

@dcalhoun dcalhoun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the memory leak is fixed. Thanks!

@oguzkocer oguzkocer merged commit 450d790 into trunk Jul 17, 2025
11 checks passed
@oguzkocer oguzkocer deleted the followup-to-allow-multiple-sites-in-android-demo-app branch July 17, 2025 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants