Repository navigation
Conversation
Root cause: Event handlers and callbacks not properly cleaned up before WebView2 controller destruction. Changes: - webview.h: Add ClearCallbacks() public method and UnregisterEventHandlers() - webview.cc: Unregister event handlers and clear callbacks before Close() - webview_bridge.cc: Control destruction order explicitly - webview.dart: Add setMuted() method for pre-dispose cleanup Tested: 100+ stress test cycles without crash Known issues (minor, deferred): - graphics_context.cc: COM object leak (once per launch) - webview_bridge.cc: Defensive callback clearing (not causing issues)
fc1bc40 to
65f8f88
Compare
|
Apologies to the maintainers and anyone following this PR. While this PR was open, I kept pushing unrelated work from my own app to the same branch ( I have reset the branch so that the PR contains only the original fix (ACCESS_VIOLATION on rapid dispose/create, 1 commit). My app's changes now live on a separate branch in my fork, and I've set up my local repository so it can no longer push to this PR branch or to this repository by mistake. If you would rather close this PR, that's completely fine. |
Summary
Problem
When a WebView is disposed and a new one is created immediately after, an ACCESS_VIOLATION can occur. This happens because:
thispointer are not cleared before destructionChanges
ClearCallbacks()public method andUnregisterEventHandlers()private methodUnregisterEventHandlers()andClearCallbacks()beforeClose()in destructorsetMuted()method for pre-dispose cleanupTesting
Tested with 100+ rapid dispose/create cycles without crash (previously crashed within 2-3 cycles).
Known Issues (minor, deferred)
graphics_context.cc: Minor COM object leak (once per app launch) - added TODO commentwebview_bridge.cc: Defensive callback clearing suggestion - added TODO comment