Boscop / web-view

Rust bindings for webview, a tiny cross-platform library to render web-based GUIs for desktop applications
MIT License
1.93k stars 176 forks source link

Segfault when running any example with Edge #71

Open green-s opened 5 years ago

green-s commented 5 years ago

When running any of the examples with the edge feature enabled I'm getting an access violation (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN).

ucrtbase.dll!abort()
ucrtbase.dll!terminate()
dialog.exe!`winrt::to_hresult'::`1'::catch$5() Line 4599
    at C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt\winrt\base.h(4599)
vcruntime140_1.dll!_CallSettingFrame_LookupContinuationIndex()
vcruntime140_1.dll!__FrameHandler4::CxxCallCatchBlock(struct _EXCEPTION_RECORD *)
ntdll.dll!RcConsolidateFrames()
dialog.exe!winrt::to_hresult() Line 4574
    at C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt\winrt\base.h(4574)
dialog.exe!`winrt::impl::delegate<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Web::UI::IWebViewControl,winrt::Windows::Web::UI::WebViewControlNavigationStartingEventArgs>>::type<<lambda_04b02dc4d8258bdef020ee9648caadb1>>::Invoke'::`1'::catch$0() Line 9017
    at C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt\winrt\base.h(9017)
vcruntime140_1.dll!_CallSettingFrame_LookupContinuationIndex()
vcruntime140_1.dll!__FrameHandler4::CxxCallCatchBlock(struct _EXCEPTION_RECORD *)
ntdll.dll!RcConsolidateFrames()
dialog.exe!winrt::impl::delegate<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Web::UI::IWebViewControl,winrt::Windows::Web::UI::WebViewControlNavigationStartingEventArgs>>::type<<lambda_04b02dc4d8258bdef020ee9648caadb1>>::Invoke(void * sender=0x0000021e6c392c80, void * args=0x0000021e6c392a00) Line 9015
    at C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt\winrt\base.h(9015)
EdgeManager.dll!Microsoft::WRL::InvokeTraits<-2>::InvokeDelegates<<lambda_6c3a5ff7cf338864a8a9147abc6a0185>,Windows::Foundation::ITypedEventHandler<WebRuntime::Diagnostics::DiagnosticsTarget * __ptr64,WebRuntime::Diagnostics::IDiagnosticsMessageReceivedEventArgs * __ptr64>>()
EdgeManager.dll!Microsoft::WRL::EventSource<struct Windows::Foundation::ITypedEventHandler<class Windows::UI::Core::CoreWindowSite *,class Windows::UI::Core::NavigationFocusEventArgs *>,struct Microsoft::WRL::InvokeModeOptions<-2> >::InvokeAll<struct Windows::UI::Core::ICoreWindowSite *,struct Windows::UI::Core::INavigationFocusEventArgs *>(struct Windows::UI::Core::ICoreWindowSite *,struct Windows::UI::Core::INavigationFocusEventArgs *)
EdgeManager.dll!Windows::Web::UI::WebViewControlBase::OnCoreWebViewNavigationStarting(struct ICoreWebViewPrivate *,struct CoreWebViewNavigationStartingEventDetails *,int *)
EdgeManager.dll!CCoreWebViewControl::CanNavigate(unsigned short *,long &)
EdgeManager.dll!CCoreWebViewControl::NavigateToStringInternal(unsigned short *)
EdgeManager.dll!CCoreWebViewControl::NavigateToString(unsigned short *)
EdgeManager.dll!Windows::Web::UI::WebViewControlBase::NavigateToString(struct HSTRING__ *)
dialog.exe!winrt::impl::consume_Windows_Web_UI_IWebViewControl<winrt::Windows::Web::UI::IWebViewControl>::NavigateToString(const winrt::param::hstring & text={...}) Line 116
    at C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt\winrt\Windows.Web.UI.h(116)
dialog.exe!webview::webview::navigate(const char * url=0x0000021e69c1eb90) Line 628
    at C:\Users\samgr\src\web-view-rs\webview-sys\webview_edge.h(628)
dialog.exe!webview_navigate(void * w=0x0000021e69c1ce50, const char * url=0x0000021e69c1eb90) Line 714
    at C:\Users\samgr\src\web-view-rs\webview-sys\webview_edge.h(714)
dialog.exe!wrapper_webview_new(const char * title=0x0000021e69c27f50, const char * url=0x0000021e69c1eb90, int width=800, int height=600, int resizable=1, int debug=1, void(*)(void *, const char *) external_invoke_cb=0x00007ff6e7d03ba0, void * userdata=0x0000021e69c29bf0) Line 15
    at C:\Users\samgr\src\web-view-rs\webview-sys\webview_edge.cc(15)
dialog.exe!web_view::WebView<()>::new<(),closure-0>(std::ffi::c_str::CStr * title=0x0000021e69c27f50, int url, int width, bool height=600, bool resizable=true, ..., dialog::main::closure-0 debug=true) Line 290
    at C:\Users\samgr\src\web-view-rs\src\lib.rs(290)
dialog.exe!web_view::WebViewBuilder<(), closure-0, str*>::build<(),closure-0,str*>(web_view::WebViewBuilder<(), closure-0, str*> self) Line 214
    at C:\Users\samgr\src\web-view-rs\src\lib.rs(214)
dialog.exe!dialog::main() Line 8
    at C:\Users\samgr\src\web-view-rs\examples\dialog.rs(8)

Minidump

richardhozak commented 5 years ago

I'll try to reproduce this.

richardhozak commented 5 years ago

So I looked a bit into this, first i thought maybe it was an older sdk, but you have the same version as me 10.0.18362.0. I remember I had problems with with compiler from MSVC 2017, could you try installing 2019 Build Tools (no need for the whole Visual Studio) and try if it fixes the issue?

green-s commented 5 years ago

I already have Visual Studio 2019 installed and as far as I know I'm using the latest build tools. I tried building from the "Developer Command Prompt for VS 2019" and "x64 Native Tools Command Prompt for VS 2019", with no difference. Did you see something that indicates that I'm using MSVC 2017?

richardhozak commented 5 years ago

Did you see something that indicates that I'm using MSVC 2017?

No it's just that I remember having problems with that. I cannot reproduce this yet, I'll try again when I have more energy to delve deeper.

FrankenApps commented 4 years ago

I have the same problem, with everything installed as suggested in the readme. EDIT: I've experienced the issue on my laptop, but not my desktop PC. Both are on windows 10.

fungos commented 4 years ago

I have a very similar problem, possible related but not exactly the same stack. The webview starts and closes almost instantly without any information, when debugging with visual studio, it is clear that there is an exception internal to webview-sys navigate function.

    void navigate(const char* url)
    {
        std::string html = html_from_uri(url);
        if (html != "") {
            m_webview.NavigateToString(winrt::to_hstring(html.c_str()));
        } else {
            Uri uri(winrt::to_hstring(url));
            m_webview.Navigate(uri);  <------ HERE
        }
    }

Then further down windows sdk will try to convert the exception using to_hresult(), which in turn calls a std::terminate(). I'll missed which was the exception, I'll try to collect more info once I'm at the problematic machine.

Windows SDK 10.0.18362.0

federico-terzi commented 4 years ago

Hey, I experienced the issue myself when trying to load a local file using the edge feature. In particular:

Steps to reproduce:

  1. Create a local file index.html with the following content:
<html lang="en">
<head>
    <title>Hello</title>   
</head>

<body>
    Hello
</body>

</html>
  1. Load the file using the File URI path:
 web_view::builder()
        .title("My Project")
        .content(Content::Url("file:///C:/Users/Freddy/Documents/testgui/index.html"))
        .size(700, 480)
        .resizable(true)
        .user_data(())
        .invoke_handler(|_webview, _arg| Ok(()))
        .run()
        .unwrap();

The script will crash with exit code: (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)

I'll try to dig myself into the code to find the root of the issue.

I'm running Visual Studio 2019

Cheers

federico-terzi commented 4 years ago

Following up to my previous comment, it turns out my use case (loading a file using the file:// protocol uri) is not currently possible. See https://github.com/windows-toolkit/WindowsCommunityToolkit/issues/2211

richardhozak commented 4 years ago

Hopefully this will be fixed, when we switch to Edge Preview, I am working on it.

federico-terzi commented 4 years ago

Glad to hear that @zxey, thanks for your reply