Skip to content

Commit 450d790

Browse files
authored
Fix WebView Memory Leak in GutenbergView (#156)
* Don't set api namespace for remote config in Android demo app * Fix WebView memory leak by adding destroy() call to onDetachedFromWindow() 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.
1 parent 59692bb commit 450d790

File tree

2 files changed

+1
-1
lines changed

2 files changed

+1
-1
lines changed

android/Gutenberg/src/main/java/org/wordpress/gutenberg/GutenbergView.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ class GutenbergView : WebView {
545545
filePathCallback = null
546546
onFileChooserRequested = null
547547
handler.removeCallbacksAndMessages(null)
548+
this.destroy()
548549
}
549550
}
550551

android/app/src/main/java/com/example/gutenbergkit/MainActivity.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ class MainActivity : AppCompatActivity(), AuthenticationManager.AuthenticationCa
8383
.setPlugins(true) // Enable plugins for remote editor
8484
.setSiteURL(config.siteUrl)
8585
.setSiteApiRoot(config.siteApiRoot)
86-
.setSiteApiNamespace(arrayOf("wp/v2"))
8786
.setNamespaceExcludedPaths(arrayOf())
8887
.setAuthHeader(config.authHeader)
8988
.build()

0 commit comments

Comments
 (0)