fix: properly destroy WebViews to prevent memory leaks
Add WebView.Destroy() call in BrowserPane.Cleanup() to unregister from global registry and release resources when closing stacked panes.
- commit
- e91cdbbc63a02270eb9e2f33f040c9649dbb1be5
- author
- bnema · · 2025-10-18 11:26 UTC
- parent
- 32de2f6
- signature
- GPG Unverified
2B82207D370127A0The key is unknown
2 files · +10 -0
M CHANGELOG.md +1 -0
| @@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file. | |||
| 21 | 21 | - Web app shortcuts: Ctrl+C, Ctrl+V, Ctrl+A now work in Gmail, VSCode web, etc. | |
| 22 | 22 | - Dark mode flash on startup: Set GTK dark theme preference and WebView background color before window/content creation | |
| 23 | 23 | - Cmd+Q and window close button now trigger graceful shutdown instead of killing the browser process | |
| 24 | + | - WebView cleanup: Properly destroy WebViews to prevent memory leaks and duplicate handler registrations when closing stacked panes | |
| 24 | 25 | ||
| 25 | 26 | ## [0.12.0] - 2025-10-16 | |
| 26 | 27 | ||
| @@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file. | |||||
| 21 | - Web app shortcuts: Ctrl+C, Ctrl+V, Ctrl+A now work in Gmail, VSCode web, etc. | 21 | - Web app shortcuts: Ctrl+C, Ctrl+V, Ctrl+A now work in Gmail, VSCode web, etc. | ||
| 22 | - Dark mode flash on startup: Set GTK dark theme preference and WebView background color before window/content creation | 22 | - Dark mode flash on startup: Set GTK dark theme preference and WebView background color before window/content creation | ||
| 23 | - Cmd+Q and window close button now trigger graceful shutdown instead of killing the browser process | 23 | - Cmd+Q and window close button now trigger graceful shutdown instead of killing the browser process | ||
| 24 | + | - WebView cleanup: Properly destroy WebViews to prevent memory leaks and duplicate handler registrations when closing stacked panes | |||
| 24 | 25 | ||||
| 25 | ## [0.12.0] - 2025-10-16 | 26 | ## [0.12.0] - 2025-10-16 | ||
| 26 | 27 | ||||
M internal/app/browser/pane.go +9 -0
| @@ -121,6 +121,15 @@ func (p *BrowserPane) Cleanup() { | |||
| 121 | 121 | } | |
| 122 | 122 | } | |
| 123 | 123 | ||
| 124 | + | // Destroy WebView to unregister from global registry and release resources | |
| 125 | + | if p.webView != nil && !p.webView.IsDestroyed() { | |
| 126 | + | if err := p.webView.Destroy(); err != nil { | |
| 127 | + | log.Printf("[pane-%s] failed to destroy webview: %v", p.id, err) | |
| 128 | + | } else { | |
| 129 | + | log.Printf("[pane-%s] successfully destroyed webview", p.id) | |
| 130 | + | } | |
| 131 | + | } | |
| 132 | + | ||
| 124 | 133 | // Clear tracking | |
| 125 | 134 | p.guiComponents = nil | |
| 126 | 135 | p.hasGUI = false | |
| @@ -121,6 +121,15 @@ func (p *BrowserPane) Cleanup() { | |||||
| 121 | } | 121 | } | ||
| 122 | } | 122 | } | ||
| 123 | 123 | ||||
| 124 | + | // Destroy WebView to unregister from global registry and release resources | |||
| 125 | + | if p.webView != nil && !p.webView.IsDestroyed() { | |||
| 126 | + | if err := p.webView.Destroy(); err != nil { | |||
| 127 | + | log.Printf("[pane-%s] failed to destroy webview: %v", p.id, err) | |||
| 128 | + | } else { | |||
| 129 | + | log.Printf("[pane-%s] successfully destroyed webview", p.id) | |||
| 130 | + | } | |||
| 131 | + | } | |||
| 132 | + | ||||
| 124 | // Clear tracking | 133 | // Clear tracking | ||
| 125 | p.guiComponents = nil | 134 | p.guiComponents = nil | ||
| 126 | p.hasGUI = false | 135 | p.hasGUI = false | ||