Skip to content

[Problem/Bug]: System.InvalidCastException occurs when setting AllowHostInputProcessing to 'true' #5394

@bhavin-prajapati

Description

@bhavin-prajapati

What happened?

I have a UWP Xbox App with a WebView2 container that points to a web URL. I've mapped the gamepad keys to manually send the KeyboardEvents into the WebView2 so I'd like to set AllowHostInputProcessing to true so the same events don't get invoked within the webview. However, when I set the AllowHostInputProcessing to true in CoreWebView2ControllerOptions, it throws 'System.InvalidCastException'. I have the latest version of WebView2 v1.0.3537.50.

Image Image Image

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

No response

Framework

WinUI2/UWP

Operating System

Windows 11

OS Version

No response

Repro steps

This code block will cause the error to occur.
`
var webView2Environment = await CoreWebView2Environment.CreateWithOptionsAsync(string.Empty, string.Empty, new CoreWebView2EnvironmentOptions()
{
AreBrowserExtensionsEnabled = true,
});
var opts = webView2Environment.CreateCoreWebView2ControllerOptions();
opts.AllowHostInputProcessing = true;

`

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions