MS Edge's组件WebView2在关闭窗口时导致c++应用程序崩溃


MS Edge runtime: 94.0.992.31
Nuget package : Microsoft.Web.WebView2  1.0.992.28

我们有两个解决方案:托管c++应用程序和Wpf GUI库。
在Managed c++中我们使用wpf的视图。
当我们使用旧的System.Windows.Controls.WebBrowser时,一切都很好。没有崩溃。但是,呈现的HTML在旧控件中变得更加复杂和难以正确呈现。因此,经过一番调查,我们决定使用微软的top edge控件。当我们测试WPF GUI项目时,一切都很好。
我们都很高兴和兴奋,它是多么的好。
然后,当我们试图将更新后的视图集成到c++应用程序时,问题出现了。如果用户从菜单中选择适当的带有WebView2控件的窗口->它成功地显示了所有必要的东西。它渲染非常复杂的html/css的方式真的很棒。
但是,当用户点击"cross"按钮,关闭相应的c++窗口(包含集成WebView2组件的wpf视图),它会立即冻结整个应用程序,几秒钟后应用程序崩溃。日志是空的,它崩溃得如此之快,以至于应用程序无法在日志中做出任何记录。
你能提供一些关于如何找到解决方法的想法吗?

更新:我在c++应用程序中订阅了application。DispatcherUnhandledException事件从WPF

void CMainFrame::OnDispatcherUnhandledException(System::Object^ sender, System::Windows::Threading::DispatcherUnhandledExceptionEventArgs^ e)
{
System::String ^ expMessage =  e->Exception->ToString();
}

它提供以下错误消息
System。InvalidOperationException: CoreWebView2成员在WebView2控件被处置后不能被访问。System.Runtime.InteropServices.COMException:组或资源没有处于执行请求操作的正确状态。(从HRESULT例外:0 x8007139f)
它看起来很奇怪,因为窗口关闭了,我们没有尝试再次打开它。
这里有一个调用栈:

System.InvalidOperationException: CoreWebView2 members cannot be accessed after the WebView2 control is disposed. ---> System.Runtime.InteropServices.COMException: The group or resource is not in the correct state to perform the requested operation. (Exception from HRESULT: 0x8007139F) at Microsoft.Web.WebView2.Core.Raw.ICoreWebView2Controller.set_IsVisible(Int32 IsVisible) at Microsoft.Web.WebView2.Core.CoreWebView2Controller.set_IsVisible(Boolean value) --- End of inner exception stack trace --- at Microsoft.Web.WebView2.Core.CoreWebView2Controller.set_IsVisible(Boolean value) at Microsoft.Web.WebView2.Wpf.WebView2.UIElement_IsVisibleChanged(Object sender, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyPropertyChangedEventHandler.Invoke(Object sender, DependencyPropertyChangedEventArgs e) at System.Windows.UIElement.RaiseDependencyPropertyChanged(EventPrivateKey key, DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.FrameworkElement.InvalidateForceInheritPropertyOnChildren(DependencyProperty property) at System.Windows.UIElement.OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.UIElement.UpdateIsVisibleCache() at System.Windows.PresentationSource.RootChanged(Visual oldRoot, Visual newRoot) at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value) at System.Windows.Interop.HwndSource.Dispose(Boolean disposing) at System.Windows.Interop.HwndSource.OnHwndDisposed(Object sender, EventArgs args) at MS.Win32.HwndWrapper.Dispose(Boolean disposing, Boolean isHwndBeingDestroyed) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

我对这个问题做了一些相关的搜索,我发现这是一个已知的问题。运行时94.0.988.0+似乎受到影响,请参考这种情况:应用程序启动后进程崩溃。

所以这似乎无法从代码中解决问题,所以如果你现在需要解决问题,你可能需要安装以前版本的Edge Dev,或者等待Edge更新。

相关内容

  • 没有找到相关文章

最新更新