In KiCad we have a dialog with a webview.
If it is opened/closed multiple times, a crash could occur.
wxWebViewEdgeImpl::OnWebViewCreated is called with a freed this in this case:
Stack trace:
wxmsw332ud_core_vc_x64_custom.dll!wxWindowIDRef::operator int() Line 136 C++
wxmsw332ud_core_vc_x64_custom.dll!wxWindowBase::GetId() Line 246 C++
wxmsw332ud_webview_vc_x64_custom.dll!wxWebViewEdgeImpl::SendErrorEventForAPI(const wxString & api={...}, HRESULT errorCode=E_ABORT Operation aborted.) Line 594 C++
> wxmsw332ud_webview_vc_x64_custom.dll!wxWebViewEdgeImpl::OnWebViewCreated(HRESULT result=E_ABORT Operation aborted., ICoreWebView2Controller * webViewController=0x0000000000000000) Line 834 C++
wxmsw332ud_webview_vc_x64_custom.dll!<lambda_b9e2d5a515577ae6803b19e130fb26d4>::operator()<long,ICoreWebView2Controller *>(HRESULT && <args_0>=E_ABORT Operation aborted., ICoreWebView2Controller * && <args_1>=0x0000000000000000) Line 479 C++
wxmsw332ud_webview_vc_x64_custom.dll!Microsoft::WRL::Details::DelegateArgTraits<long (__cdecl ICoreWebView2CreateCoreWebView2ControllerCompletedHandler::*)(long,ICoreWebView2Controller *)>::DelegateInvokeHelper<ICoreWebView2CreateCoreWebView2ControllerCompletedHandler,<lambda_b9e2d5a515577ae6803b19e130fb26d4>,1,long,ICoreWebView2Controller *>::Invoke(HRESULT <args_0>=E_ABORT Operation aborted., ICoreWebView2Controller * <args_1>=0x0000000000000000) Line 354 C++
EmbeddedBrowserWebView.dll!base::internal::Invoker<base::internal::FunctorTraits<`lambda at ..\..\edge_embedded_browser\client\win\current\embedded_browser_webview_environment.cc:1679:11' &&,ICoreWebView2CreateCoreWebView2ControllerCompletedHandler *>,base::internal::BindState<0,0,0,`lambda at ..\..\edge_embedded_browser\client\win\current\embedded_browser_webview_environment.cc:1679:11',Microsoft::WRL::ComPtr<ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>>,void (long, embedded_browser_webview_current::Controller *)>::RunOnce() Unknown
EmbeddedBrowserWebView.dll!embedded_browser_webview_current::internal::EBWebViewEnvironment::RetryCreateWebView() Unknown
EmbeddedBrowserWebView.dll!base::internal::Invoker<base::internal::FunctorTraits<void (embedded_browser_webview_current::internal::EBWebViewEnvironment::*&&)(Microsoft::WRL::ComPtr<embedded_browser_webview_current::Controller>, std::__Cr::unique_ptr<embedded_browser_webview_current::WebViewCreationParams,std::__Cr::default_delete<embedded_browser_webview_current::WebViewCreationParams>>),embedded_browser_webview_current::internal::EBWebViewEnvironment *,embedded_browser_webview_current::Controller *>,base::internal::BindState<1,1,0,void (embedded_browser_webview_current::internal::EBWebViewEnvironment::*)(Microsoft::WRL::ComPtr<embedded_browser_webview_current::Controller>, std::__Cr::unique_ptr<embedded_browser_webview_current::WebViewCreationParams,std::__Cr::default_delete<embedded_browser_webview_current::WebViewCreationParams>>),base::internal::RetainedRefWrapper<embedded_browser_webview_current::internal::EBWebViewEnvironment>,Microsoft::WRL::ComPtr<embedded_browser_webview_current::Controller>>,void (std::__Cr::unique_ptr<embedded_browser_webview_current::WebViewCreationParams,std::__Cr::default_delete<embedded_browser_webview_current::WebViewCreationParams>>)>::RunOnce() Unknown
EmbeddedBrowserWebView.dll!base::OnceCallback<void (std::__Cr::unique_ptr<embedded_browser_webview_current::WebViewCreationParams,std::__Cr::default_delete<embedded_browser_webview_current::WebViewCreationParams>>)>::Run() Unknown
EmbeddedBrowserWebView.dll!embedded_browser_webview_current::EmbeddedBrowserWebView::CloseInternal(long,bool,enum embedded_browser_webview::WebViewCloseReason) Unknown
EmbeddedBrowserWebView.dll!embedded_browser_webview_current::Controller::Close(void) Unknown
EmbeddedBrowserWebView.dll!embedded_browser_webview_current::internal::ClientWindowWin32::_ProcessWindowMessage() Unknown
EmbeddedBrowserWebView.dll!embedded_browser_webview_current::internal::ClientWindowWin32::ProcessWindowMessage(struct HWND__ *,unsigned int,unsigned __int64,__int64,__int64 &,unsigned long) Unknown
EmbeddedBrowserWebView.dll!gfx::WindowImpl::OnWndProc() Unknown
EmbeddedBrowserWebView.dll!gfx::WindowImpl::WndProc() Unknown
EmbeddedBrowserWebView.dll!base::win::WrappedWindowProc<&gfx::WindowImpl::WndProc>() Unknown
user32.dll!UserCallWinProcCheckWow(struct _ACTIVATION_CONTEXT *,__int64 (*)(struct tagWND *,unsigned int,unsigned __int64,__int64),struct HWND__ *,enum _WM_VALUE,unsigned __int64,__int64,void *,int) Unknown
user32.dll!DispatchClientMessage() Unknown
user32.dll!__fnNCDESTROY() Unknown
ntdll.dll!KiUserCallbackDispatcherContinue() Unknown
win32u.dll!NtUserDestroyWindow() Unknown
wxmsw332ud_core_vc_x64_custom.dll!wxWindow::~wxWindow() Line 429 C++
wxmsw332ud_core_vc_x64_custom.dll!wxControlBase::~wxControlBase() Line 47 C++
wxmsw332ud_core_vc_x64_custom.dll!wxControl::~wxControl() C++
wxmsw332ud_webview_vc_x64_custom.dll!wxWebView::~wxWebView() Line 217 C++
wxmsw332ud_webview_vc_x64_custom.dll!wxWebViewEdge::~wxWebViewEdge() Line 1070 C++
wxmsw332ud_webview_vc_x64_custom.dll!wxWebViewEdge::`vector deleting destructor'(unsigned int) C++
wxmsw332ud_core_vc_x64_custom.dll!wxWindowBase::Destroy() Line 570 C++
wxmsw332ud_core_vc_x64_custom.dll!wxWindowBase::DestroyChildren() Line 602 C++
wxmsw332ud_core_vc_x64_custom.dll!wxWindow::~wxWindow() Line 420 C++
wxmsw332ud_core_vc_x64_custom.dll!wxNavigationEnabled<wxWindow>::~wxNavigationEnabled<wxWindow>() C++
wxmsw332ud_core_vc_x64_custom.dll!wxPanel::~wxPanel() C++
kicad.exe!WEBVIEW_PANEL::~WEBVIEW_PANEL() Line 111 C++
kicad.exe!WEBVIEW_PANEL::`scalar deleting destructor'(unsigned int) C++
wxmsw332ud_core_vc_x64_custom.dll!wxWindowBase::Destroy() Line 570 C++
wxmsw332ud_core_vc_x64_custom.dll!wxWindowBase::DestroyChildren() Line 602 C++
wxmsw332ud_core_vc_x64_custom.dll!wxWindow::~wxWindow() Line 420 C++
wxmsw332ud_core_vc_x64_custom.dll!wxNavigationEnabled<wxWindow>::~wxNavigationEnabled<wxWindow>() C++
wxmsw332ud_core_vc_x64_custom.dll!wxPanel::~wxPanel() C++
kicad.exe!wxPanel::`scalar deleting destructor'(unsigned int) C++
wxmsw332ud_core_vc_x64_custom.dll!wxWindowBase::Destroy() Line 570 C++
wxmsw332ud_core_vc_x64_custom.dll!wxWindowBase::DestroyChildren() Line 602 C++
wxmsw332ud_core_vc_x64_custom.dll!wxWindow::~wxWindow() Line 420 C++
wxmsw332ud_core_vc_x64_custom.dll!wxNavigationEnabled<wxWindow>::~wxNavigationEnabled<wxWindow>() C++
wxmsw332ud_core_vc_x64_custom.dll!wxPanel::~wxPanel() C++
kicad.exe!wxPanel::`scalar deleting destructor'(unsigned int) C++
wxmsw332ud_core_vc_x64_custom.dll!wxWindowBase::Destroy() Line 570 C++
wxmsw332ud_core_vc_x64_custom.dll!wxWindowBase::DestroyChildren() Line 602 C++
wxmsw332ud_core_vc_x64_custom.dll!wxWindow::~wxWindow() Line 420 C++
wxmsw332ud_core_vc_x64_custom.dll!wxNonOwnedWindowBase::~wxNonOwnedWindowBase() C++
wxmsw332ud_core_vc_x64_custom.dll!wxNonOwnedWindow::~wxNonOwnedWindow() Line 157 C++
wxmsw332ud_core_vc_x64_custom.dll!wxTopLevelWindowBase::~wxTopLevelWindowBase() Line 100 C++
wxmsw332ud_core_vc_x64_custom.dll!wxTopLevelWindowMSW::~wxTopLevelWindowMSW() Line 523 C++
wxmsw332ud_core_vc_x64_custom.dll!wxTopLevelWindow::~wxTopLevelWindow() C++
wxmsw332ud_core_vc_x64_custom.dll!wxNavigationEnabled<wxTopLevelWindow>::~wxNavigationEnabled<wxTopLevelWindow>() C++
wxmsw332ud_core_vc_x64_custom.dll!wxDialogBase::~wxDialogBase() Line 70 C++
wxmsw332ud_core_vc_x64_custom.dll!wxDialog::~wxDialog() Line 189 C++
kicommon.dll!DIALOG_SHIM::~DIALOG_SHIM() Line 285 C++
kicad.exe!DIALOG_TEMPLATE_SELECTOR_BASE::~DIALOG_TEMPLATE_SELECTOR_BASE() Line 144 C++
kicad.exe!DIALOG_TEMPLATE_SELECTOR::~DIALOG_TEMPLATE_SELECTOR() Line 563 C++
kicad.exe!KICAD_MANAGER_CONTROL::NewProject::__l2::<lambda_1>::operator()() Line 272 C++
kicad.exe!std::invoke<`KICAD_MANAGER_CONTROL::NewProject'::`2'::<lambda_1> &>(KICAD_MANAGER_CONTROL::NewProject::__l2::<lambda_1> & _Obj={...}) Line 1678 C++
kicad.exe!std::_Func_impl_no_alloc<`KICAD_MANAGER_CONTROL::NewProject'::`2'::<lambda_1>,void>::_Do_call() Line 883 C++
kicad.exe!std::_Func_class<void>::operator()() Line 930 C++
kicad.exe!COROUTINE<int,TOOL_EVENT const &>::CALL_CONTEXT::Continue(COROUTINE<int,TOOL_EVENT const &>::INVOCATION_ARGS * args=0x000002c98132e198) Line 180 C++
kicad.exe!COROUTINE<int,TOOL_EVENT const &>::Call(const TOOL_EVENT & aArg={...}) Line 299 C++
kicad.exe!TOOL_MANAGER::dispatchInternal(TOOL_EVENT & aEvent={...}) Line 857 C++
kicad.exe!TOOL_MANAGER::processEvent(const TOOL_EVENT & aEvent={...}) Line 1204 C++
kicad.exe!TOOL_MANAGER::ProcessEvent(const TOOL_EVENT & aEvent={...}) Line 1064 C++
kicad.exe!ACTION_MENU::OnMenuEvent(wxMenuEvent & aEvent={...}) Line 598 C++
wxbase332ud_vc_x64_custom.dll!wxAppConsoleBase::HandleEvent(wxEvtHandler * handler=0x000002c9802058c0, void(wxEvtHandler::*)(wxEvent &) func=0x000000f107cfec00, wxEvent & event={...}) Line 681 C++
wxbase332ud_vc_x64_custom.dll!wxAppConsoleBase::CallEventHandler(wxEvtHandler * handler=0x000002c9802058c0, wxEventFunctor & functor={...}, wxEvent & event={...}) Line 693 C++
wxbase332ud_vc_x64_custom.dll!wxEvtHandler::ProcessEventIfMatchesId(const wxEventTableEntryBase & entry={...}, wxEvtHandler * handler=0x000002c9802058c0, wxEvent & event={...}) Line 1468 C++
wxbase332ud_vc_x64_custom.dll!wxEvtHandler::SearchDynamicEventTable(wxEvent & event={...}) Line 1928 C++
wxbase332ud_vc_x64_custom.dll!wxEvtHandler::TryHereOnly(wxEvent & event={...}) Line 1651 C++
wxbase332ud_vc_x64_custom.dll!wxEvtHandler::TryBeforeAndHere(wxEvent & event={...}) Line 4078 C++
wxbase332ud_vc_x64_custom.dll!wxEvtHandler::ProcessEventLocally(wxEvent & event={...}) Line 1588 C++
wxbase332ud_vc_x64_custom.dll!wxEvtHandler::ProcessEvent(wxEvent & event={...}) Line 1561 C++
wxbase332ud_vc_x64_custom.dll!wxEvtHandler::SafelyProcessEvent::__l2::<lambda>() Line 1676 C++
wxbase332ud_vc_x64_custom.dll!wxSafeCall<bool,bool <lambda>(void),bool <lambda>(void)>(const wxEvtHandler::SafelyProcessEvent::__l2::bool <lambda>(void) & func=bool <lambda>(void){...}, const wxEvtHandler::SafelyProcessEvent::__l2::bool <lambda>(void) & handler=bool <lambda>(void){...}) Line 40 C++
wxbase332ud_vc_x64_custom.dll!wxEvtHandler::SafelyProcessEvent(wxEvent & event={...}) Line 1684 C++
wxmsw332ud_core_vc_x64_custom.dll!wxMenuBase::DoProcessEvent(wxMenuBase * menu=0x000002c9802058c0, wxEvent & event={...}, wxWindow * win=0x000002c9f4abca10) Line 703 C++
wxmsw332ud_core_vc_x64_custom.dll!wxMenuBase::SendEvent(int itemid=20001, int checked=-1) Line 675 C++
wxmsw332ud_core_vc_x64_custom.dll!wxFrameBase::ProcessCommand(wxMenuItem * item=0x000002c980315f40) Line 387 C++
wxmsw332ud_core_vc_x64_custom.dll!wxFrame::HandleCommand(unsigned short id=20001, unsigned short cmd=0, HWND__ * control=0x0000000000000000) Line 821 C++
wxmsw332ud_core_vc_x64_custom.dll!wxFrame::MSWWindowProc(unsigned int message=273, unsigned __int64 wParam=20001, __int64 lParam=0) Line 941 C++
kicad.exe!EDA_BASE_FRAME::MSWWindowProc(unsigned int message=273, unsigned __int64 wParam=20001, __int64 lParam=0) Line 2003 C++
wxmsw332ud_core_vc_x64_custom.dll!wxWndProc(HWND__ * hWnd=0x0000000008d411b0, unsigned int message=273, unsigned __int64 wParam=20001, __int64 lParam=0) Line 2980 C++
user32.dll!UserCallWinProcCheckWow(struct _ACTIVATION_CONTEXT *,__int64 (*)(struct tagWND *,unsigned int,unsigned __int64,__int64),struct HWND__ *,enum _WM_VALUE,unsigned __int64,__int64,void *,int) Unknown
user32.dll!DispatchMessageWorker() Unknown
wxmsw332ud_core_vc_x64_custom.dll!wxGUIEventLoop::ProcessMessage(tagMSG * msg=0x000000f107cff728) Line 148 C++
wxmsw332ud_core_vc_x64_custom.dll!wxGUIEventLoop::Dispatch() Line 202 C++
wxbase332ud_vc_x64_custom.dll!wxEventLoopManual::ProcessEvents() Line 247 C++
wxbase332ud_vc_x64_custom.dll!wxEventLoopManual::DoRunLoop() Line 288 C++
wxbase332ud_vc_x64_custom.dll!wxEventLoopManual::DoRun::__l4::<lambda>() Line 369 C++
wxbase332ud_vc_x64_custom.dll!wxSafeCall<void,void <lambda>(void),void <lambda>(void)>(const wxEventLoopManual::DoRun::__l4::void <lambda>(void) & func=void <lambda>(void){...}, const wxEventLoopManual::DoRun::__l4::void <lambda>(void) & handler=void <lambda>(void){...}) Line 40 C++
wxbase332ud_vc_x64_custom.dll!wxEventLoopManual::DoRun() Line 364 C++
wxbase332ud_vc_x64_custom.dll!wxEventLoopBase::Run() Line 88 C++
wxbase332ud_vc_x64_custom.dll!wxAppConsoleBase::MainLoop() Line 393 C++
wxbase332ud_vc_x64_custom.dll!wxAppConsoleBase::OnRun() Line 292 C++
wxmsw332ud_core_vc_x64_custom.dll!wxAppBase::OnRun() Line 351 C++
kicad.exe!APP_KICAD::OnRun() Line 547 C++
wxbase332ud_vc_x64_custom.dll!wxEntryReal::__l2::<lambda>() Line 563 C++
wxbase332ud_vc_x64_custom.dll!wxSafeCall<int,int <lambda>(void),int <lambda>(void)>(const wxEntryReal::__l2::int <lambda>(void) & func=int <lambda>(void){...}, const wxEntryReal::__l2::int <lambda>(void) & handler=int <lambda>(void){...}) Line 40 C++
wxbase332ud_vc_x64_custom.dll!wxEntryReal(int & argc=1, wchar_t * * argv=0x000002c9f40e9780) Line 550 C++
wxbase332ud_vc_x64_custom.dll!wxEntry(int & argc=1, wchar_t * * argv=0x000002c9f40e9780) Line 176 C++
wxmsw332ud_core_vc_x64_custom.dll!wxEntry(HINSTANCE__ * hInstance=0x00007ff666b10000, HINSTANCE__ * __formal=0x0000000000000000, char * __formal=0x000002c9f220d12e, int nCmdShow=10) Line 227 C++
kicad.exe!WinMain(HINSTANCE__ * hInstance=0x00007ff666b10000, HINSTANCE__ * hPrevInstance=0x0000000000000000, char * lpCmdLine=0x000002c9f220d12e, int nCmdShow=10) Line 650 C++
kicad.exe!invoke_main() Line 107 C++
kicad.exe!__scrt_common_main_seh() Line 288 C++
kicad.exe!__scrt_common_main() Line 331 C++
kicad.exe!WinMainCRTStartup(void * __formal=0x000000f107bfa000) Line 17 C++
kernel32.dll!BaseThreadInitThunk() Unknown
ntdll.dll!RtlUserThreadStart() Unknown
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.![]()
This callback gets called after delete m_impl; in wxWebViewEdge::~wxWebViewEdge
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.![]()
@vadz Just wondering if you've seen this.
(I could only see this crash in Debug builds for some reason)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
I can reproduce it in the modified minimal sample, when closing the dialog immediately after opening (F1) it, so before the page loads.
A possible fix is to not send events for E_ABORT.
As a workaround, maybe you can block closing of the dialog until wxEVT_WEBVIEW_CREATED is received. (I have not tried this)
diff --git "a/src/msw/webview_edge.cpp" "b/src/msw/webview_edge.cpp" index cf6f80e869..0ab1c9c5a0 100644 --- "a/src/msw/webview_edge.cpp" +++ "b/src/msw/webview_edge.cpp" @@ -865,7 +865,8 @@ HRESULT wxWebViewEdgeImpl::OnWebViewCreated(HRESULT result, ICoreWebView2Control { if (FAILED(result)) { - SendErrorEventForAPI("WebView2::WebViewCreated", result); + if ( result != E_ABORT ) + SendErrorEventForAPI("WebView2::WebViewCreated", result); return result; }
Test code, also link with webview library:
diff --git "a/samples/minimal/minimal.cpp" "b/samples/minimal/minimal.cpp" index 5f32257c6b..208ef1f189 100644 --- "a/samples/minimal/minimal.cpp" +++ "b/samples/minimal/minimal.cpp" @@ -25,6 +25,7 @@ #ifndef WX_PRECOMP #include "wx/wx.h" #endif +#include <wx/webview.h> // ---------------------------------------------------------------------------- // resources @@ -69,6 +70,15 @@ private: wxDECLARE_EVENT_TABLE(); }; +class WebDialog : public wxDialog { +public: + WebDialog(MyFrame* frame, const wxString& title) + : wxDialog(frame, wxID_ANY, title, wxDefaultPosition, frame->FromDIP(wxSize(800, 600))) + { + wxWebView::New(this, wxID_ANY, "https://wxwidgets.org/"); + } +}; + // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- @@ -188,16 +198,6 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { - wxMessageBox(wxString::Format - ( - "Welcome to %s!\n" - "\n" - "This is the minimal wxWidgets sample\n" - "running under %s.", - wxVERSION_STRING, - wxGetOsDescription() - ), - "About wxWidgets minimal sample", - wxOK | wxICON_INFORMATION, - this); + WebDialog dialog(this, "wxWebView"); + dialog.ShowModal(); }
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
Just wondering if you've seen this.
No, I've somehow missed this one :-( Thanks Maarten for the reproducer, I'll look at it later.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()