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]: Gamepad and Pointer Lock APIs not working in "Window to visual" hosting mode #4968

Open
AshleyScirra opened this issue Dec 4, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@AshleyScirra
Copy link

What happened?

When WebView2 is set to use "Window to visual" hosting mode, the Pointer Lock API no longer works correctly in web content.

This is a potential blocker for Construct migrating from NW.js to WebView2.

Importance

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

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

131.0.2903.70

SDK Version

1.0.2903.40

Framework

Win32

Operating System

Windows 11

OS Version

22631.4460

Repro steps

For a minimal repro, use the Win32_GettingStarted sample, and make the following changes:

  1. Add the following line before CreateCoreWebView2EnvironmentWithOptions() to set "Window to visual" hosting mode:

SetEnvironmentVariable(L"COREWEBVIEW2_FORCED_HOSTING_MODE", L"COREWEBVIEW2_HOSTING_MODE_WINDOW_TO_VISUAL");

  1. Change the URL in the call to webview->Navigate(...) to: https://downloads.scirra.com/labs/bugs/pointerlocktest.html

Now run the app and click 'Get pointer lock'.

Observed result: the mouse cursor remains visible, and the page does not update with any more pointermove events. Further, the notification saying "to show your cursor, press Esc" appears offset, sometimes outside the window (ideally we would hide this notification as it's not applicable to desktop software - see #4960). Further, after pressing Esc pointer events don't seem to restart again, leaving the app in a stuck state.

Expected result: pointer lock to work normally as it does in a web browser, or in the standard windowed hosting mode. Comment out the line added in step 1 to use windowed hosting mode, and you'll see it works correctly.

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

@AshleyScirra AshleyScirra added the bug Something isn't working label Dec 4, 2024
@AshleyScirra AshleyScirra changed the title [Problem/Bug]: Pointer Lock API does not work in "Window to visual" hosting mode [Problem/Bug]: Gamepad and Pointer Lock APIs not working in "Window to visual" hosting mode Dec 4, 2024
@AshleyScirra
Copy link
Author

AshleyScirra commented Dec 4, 2024

Further testing also indicates that the Gamepad API does not work in this mode either - change the URL to https://hardwaretester.com/gamepad to test that. This is a blocker for web gaming content.

We're trying to use the "Window to visual" hosting mode for better compatibility with the Steam Overlay, as "Windowed" mode doesn't work, and there still doesn't appear to be support for rendering to texture to work around that (#20, #547), so we're trying different WebView2 hosting modes. Regardless, these APIs should work in "Window to visual" mode, as the documentation says it should basically work the same as windowed mode without any API differences.

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