Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Crash when accessing new WebView2 types in WinAppSDK 1.5 #4421

Closed
softworkz opened this issue Mar 13, 2024 · 3 comments
Closed

[Bug]: Crash when accessing new WebView2 types in WinAppSDK 1.5 #4421

softworkz opened this issue Mar 13, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@softworkz
Copy link

softworkz commented Mar 13, 2024

What happened?

There appears to be a mistake in compilation of WebView2Core bindings in WinAppSDK 1.5.

Newly added members (since 1.4) cannot be invoked.

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

No response

SDK Version

122.0.2365.80 (doesn't really matter)

Framework

WinUI3/WinAppSDK

Operating System

Windows 11

OS Version

22621.2506

Repro steps

Repro project here: softworkz/WinUI3WebView2ExtensionsBug
.
Or just execute this code snippet in a C# WinUI3 project, updated to WinAppSDK 1.5.240311000:

            var options = new CoreWebView2EnvironmentOptions();
            options.AdditionalBrowserArguments = "--enable-disble ";
            options.AreBrowserExtensionsEnabled = true;

Related: microsoft/microsoft-ui-xaml#9437

@softworkz softworkz added the bug Something isn't working label Mar 13, 2024
@softworkz
Copy link
Author

I believe that this is not something for the WebView2 team, that's why I had also posted it @ microsoft-ui-xaml.

But I still have a

Question

Maybe you can help me out for working around this in some way. I need to add a browser extension and that's exactly what is not working:

1 CoreWebView2EnvironmentOptions.AreBrowserExtensionsEnabled
2 CoreWebView2.Profile.AddBrowserExtensionAsync()

For 2, I found out that I can also use the command line arg --load-extension=path-to-extension

But I can't find something to achieve 1 in a diffeent way. I tried things like:

            arguments += "  --enable-edge-extensions  --enable-extensions  ";
           .....
            Environment.SetEnvironmentVariable("WEBVIEW2_EDGE_EXTENSIONS_ENABLED", "1");
            Environment.SetEnvironmentVariable("WEBVIEW2_EDGE_EXTENSIONS", "1");
            Environment.SetEnvironmentVariable("WEBVIEW2_EXTENSIONS_ENABLED", "1");
            Environment.SetEnvironmentVariable("WEBVIEW2_EXTENSIONS", "1")

...without success.

Is there any other way to enable extensions in the WebView2?
(registry, command line, environment, policies)

Thanks

@softworkz
Copy link
Author

softworkz commented Mar 14, 2024

I figured it out (the question for a workaround - not the cause of the issue):

CoreWebView2.Profile.AddBrowserExtensionAsync() can be substituted by adding this

 --load-extension=\"{extensionDir}\" 

And CoreWebView2EnvironmentOptions.AreBrowserExtensionsEnabled can be replaced by this undocumented command line switch:

--embedded-browser-webview-enable-extension

@dianaqu
Copy link
Contributor

dianaqu commented Apr 3, 2024

Fix will be available on next SDK release

@dianaqu dianaqu closed this as completed May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants