File tree Expand file tree Collapse file tree
src/Eto.Wpf/Forms/Controls Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -473,10 +473,23 @@ protected override void OnInitializeComplete()
473473 InitializeAsync ( ) ;
474474 }
475475
476+ // E_ABORT - reported when initialization is aborted because the control was
477+ // torn down before EnsureCoreWebView2Async completed.
478+ const int E_ABORT = unchecked ( ( int ) 0x80004004 ) ;
479+
476480 void Control_CoreWebView2Ready ( object sender , CoreWebView2InitializationCompletedEventArgs e )
477481 {
478482 if ( ! e . IsSuccess )
479483 {
484+ // When the control is disposed/unloaded before WebView2 finishes initializing
485+ // (e.g. closing a panel or switching the window/viewport layout) the
486+ // initialization is aborted with E_ABORT. This is benign and must not be
487+ // allowed to escape this native callback, since it would surface as an
488+ // unhandled exception on the dispatcher and crash the application.
489+ // https://github.com/MicrosoftEdge/WebView2Feedback/issues/2410
490+ if ( Widget . IsDisposed || e . InitializationException ? . HResult == E_ABORT )
491+ return ;
492+
480493 throw new WebView2InitializationException ( "Failed to initialize WebView2" , e . InitializationException ) ;
481494 }
482495
You can’t perform that action at this time.
0 commit comments