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

[Problem/Bug]: WinRT UWP - Error: Bad variable type. (0x80020008) #4934

Open
BirknerAlex opened this issue Nov 18, 2024 · 0 comments
Open

[Problem/Bug]: WinRT UWP - Error: Bad variable type. (0x80020008) #4934

BirknerAlex opened this issue Nov 18, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@BirknerAlex
Copy link

What happened?

I am trying to migrate the UWP App from WebView to WebView2, mostly everything is working except talking to the Microsoft Store API. Calling the API results in an exception Error: Bad variable type. (0x80020008).

With the previous WebView (1) implementation we are fine but the legacy WebView is crashing on the latest Xbox OS update (Oct 2024) - only on Xbox by the way - so we need someone a fix of the Xbox OS WebView (1) or getting our App to work with WebView2 instead.

Importance

Blocking. My app's basic functions are not working due to this issue.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

No response

SDK Version

1.0.2903.40

Framework

WinUI2/UWP

Operating System

Windows 11, Xbox

OS Version

10.0.22621

Repro steps

Basically I followed the guideline from https://learn.microsoft.com/en-us/microsoft-edge/webview2/how-to/winrt-from-js

I build the WinRTAdapter by including following APIs:

Windows.Services.Store
Windows.Services.Store.StorePurchaseStatus
Windows.Services.Store.StoreContext
Windows.System.Launcher
Windows.Foundation.Uri
Windows.UI.ViewManagement.ApplicationViewScaling
Windows.ApplicationModel.Package

How I have initialized the WebView2 instance on the UWP App:

private async void InitializeWebView2Async()
{
    webView = new WebView2();
    webView.Source = new Uri(ENTRYPOINT);

    await webView.EnsureCoreWebView2Async();

    // This injects the legacy WinRT javascript objects into the WebView2 environment
    var dispatchAdapter = new WinRTAdapter.DispatchAdapter();
    webView.CoreWebView2.AddHostObjectToScript("Windows", dispatchAdapter.WrapNamedObject("Windows", dispatchAdapter));

    rootGrid.Children.Add(webView);
}

In the JS application I am running:

// bootstrap
chrome.webview.hostObjects.options.forceAsyncMethodMatches = [/Async$/];
const Windows = chrome.webview.hostObjects.sync.Windows;

// works
const store = windows.Services.Store.StoreContext.getDefault();

// throws error
store.getAssociatedStoreProductsAsync(['Durable']).then((data) => {
  if (data?.products) productsCallback(data.products)
})

And calling getAssociatedStoreProductsAsync is the moment where the error happens. I think it has something todo with the encoding of the StoreProductQueryResult response to the WebView?

I would be very glad if someone could help from the MS team; we really having issues after the latest Xbox Update to restore our app functionality.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

@BirknerAlex BirknerAlex added the bug Something isn't working label Nov 18, 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

2 participants