MicrosoftEdge / MicrosoftEdge/WebView2Feedback
[Problem/Bug]: WinRT UWP - Error: Bad variable type. (0x80020008)
@jennifer-nejad is already working on this.
Since Nov 22, 2024.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.