WebView2 in x86 app

Hi everyone,

I’m unable to use WebBrowserComponent with JUCE_USE_WIN_WEBVIEW2 (WebView2Loader.dll) in a Win32 (x86) app. When WebView2 constructor calls “webViewHandle = std::move(*handle)” an access violation reading location crashes the app.

WebView2
…\juce_gui_extra\native\juce_win32_WebBrowserComponent.cpp

Using the x64 architecture, I have no problems.

To reproduce this error; create a GUI project with VS 2022 exporter, change the architecture to Win32 (Debug and Release configuration), enable the juce_gui_extra module and enable JUCE_USE_WIN_WEBVIEW2.

Source code example;

MainComponent::MainComponent()
{

File data("C:\\myapp\\userdata\\");
WebBrowserComponent::Options::WinWebView2 winWebView2;
winWebView2 = winWebView2.withUserDataFolder(data);
WebBrowserComponent::Options options;
options = options.withBackend(WebBrowserComponent::Options::Backend::webview2);
options = options.withWinWebView2Options(winWebView2);

webBrowser = std::make_unique<WebBrowserComponent>(options);
addAndMakeVisible(*webBrowser);
webBrowser->goToURL("https://forum.juce.com");
setSize(600, 400);

}

Callstack after call the WebView2 constructor

00aff400() Unknown
[Frames below may be incorrect and/or missing]
[External Code]
> NewProject.exe!juce::WebView2::WebView2(juce::WebBrowserComponent & o, const juce::WebBrowserComponent::Options & prefs) Line 368 C++
[External Code]
NewProject.exe!std::_Optional_construct_basejuce::WebView2::WebViewHandle::_Optional_construct_basejuce::WebView2::WebViewHandlejuce::WebView2::WebViewHandle(std::in_place_t __param0, juce::WebView2::WebViewHandle && __param1) Line 9 C++
NewProject.exe!std::_Non_trivial_move<std::_Optional_construct_basejuce::WebView2::WebViewHandle,juce::WebView2::WebViewHandle>::_Non_trivial_move<std::_Optional_construct_basejuce::WebView2::WebViewHandle,juce::WebView2::WebViewHandle>juce::WebView2::WebViewHandle(std::in_place_t __param0, juce::WebView2::WebViewHandle && __param1) Line 9 C++
NewProject.exe!std::_Deleted_copy_assign<std::_Optional_construct_basejuce::WebView2::WebViewHandle,juce::WebView2::WebViewHandle>::_Deleted_copy_assign<std::_Optional_construct_basejuce::WebView2::WebViewHandle,juce::WebView2::WebViewHandle>juce::WebView2::WebViewHandle(std::in_place_t __param0, juce::WebView2::WebViewHandle && __param1) Line 9 C++
NewProject.exe!std::_Non_trivial_move_assign<std::_Optional_construct_basejuce::WebView2::WebViewHandle,juce::WebView2::WebViewHandle>::_Non_trivial_move_assign<std::_Optional_construct_basejuce::WebView2::WebViewHandle,juce::WebView2::WebViewHandle>juce::WebView2::WebViewHandle(std::in_place_t __param0, juce::WebView2::WebViewHandle && __param1) Line 9 C++

Despite this, using Microsoft’s webview2 sample application, I have no problems building with x86 architecture.

In my app, the x86 Debug Build worked, but only the x86 Release Build went wrong. x64 Debug/Release are both normal. Thank you for information. If it weren’t for this comment, I think I would have wasted another week. JUCE version is old 6.1.6 WebView2 runtime version is 120.0. XXXX.XX (latest of 2023 Dec.)

1 Like