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

Gamepad API only works when developer tools is opened. #3025

Closed
abiliaorg opened this issue Dec 6, 2022 · 46 comments
Closed

Gamepad API only works when developer tools is opened. #3025

abiliaorg opened this issue Dec 6, 2022 · 46 comments
Assignees
Labels
bug Something isn't working status-circle back Check back after requesting general information. tracked We are tracking this work internally.

Comments

@abiliaorg
Copy link

abiliaorg commented Dec 6, 2022

Description
I'm creating a videogame using Gamepad API running on a WebView2 instance. Anytime I use my Gamepad (SPEEDLINK COMPETITION PRO) it does not work if I focus on the browser window. Whenever I open the developer tools and I focus on that window, the gamepad is recognized and the videogame receives gamepad events.

Version
SDK: 1.0.1150.38
Runtime: Edge WebView2 Runtime 107.0.1418.62
Framework: .NET Framework 4.8
OS: Win10

Repro Steps

  • Run WebView2 and open https://gamepad-tester.com/
  • Test it with browser window focused -> gamepad not recognized
  • Test it with dev tools window focused -> gamepad recognized and working

AB#42714785

@abiliaorg abiliaorg added the bug Something isn't working label Dec 6, 2022
@victorthoang
Copy link

Hello @abiliaorg,

Thanks for your bug report. I've assigned this to a dev that can best try to replicate the issue and follow up on this.

@novac42 novac42 assigned novac42, nanaliulei and ElyssaJyu and unassigned imicy and nanaliulei Dec 8, 2022
@ElyssaJyu
Copy link

@abiliaorg Do you use WPF/WinForms framework with WebView2 control? Also, Could you share some sample code to show Gamepad API using?

@RonenNess
Copy link

Hello @ElyssaJyu, @victorthoang ,

GamePad stopped working in WebView completely, with or without the developer console.
It used to work fine in the past, I'm not sure when it got broken.

Here's a tiny project to illustrate this using Photino (a lean C# WebView wrapper):

https://github.com/RonenNess/WebView-Gamepad-Issue

It loads the index.html file under wwwroot that alert and write to console when a gamepad is connected.
If you open the HTML file directly and serve it from filesystem with other browsers, you'd see it works. With WebView, it doesn't respond. You can also load the https://gamepad-tester.com/ site instead of the local HTML file, same result.

Please fix this is really harmful for people who use WebViews to render HTML games locally..

Thanks.

@ElyssaJyu
Copy link

ElyssaJyu commented Dec 20, 2022

@RonenNess
Hi, it's a little bit confused to me. Your project seems to use Photino.NET package, not WebView2. Could you please give additional information about how you use webview2? Thanks.

@ElyssaJyu
Copy link

As you mentioned, you use Photino which is a lean C# WebView wrapper. May need time to investigate it.
Also, we have WPF and WinForms app which have webview2 control. You can try them to use WebView2 to render HTML games.

@RonenNess
Copy link

@RonenNess Hi, it's a little bit confused to me. Your project seems to use Photino.NET package, not WebView2. Could you please give additional information about how you use webview2? Thanks.

Photino on windows is just a wrapper around WebView2.

If you want I can make a forms project later at home, the result will probably remain the same.

@RonenNess
Copy link

RonenNess commented Dec 20, 2022

As you mentioned, you use Photino which is a lean C# WebView wrapper. May need time to investigate it. Also, we have WPF and WinForms app which have webview2 control. You can try them to use WebView2 to render HTML games.

Here, with forms and Microsoft official controller

https://github.com/RonenNess/WebView-Gamepad-Issue/tree/main/WithForm/PlsFixGamepad/PlsFixGamepad

Same result. The issue is with the WebView2 itself. The version of the NuGet doesn't matter either, tried older versions too.

Tested gamepad: xbox controller

@ElyssaJyu
Copy link

Hi @RonenNess, Thanks for your sample projects to help us reproduce the issue!
I have tried both with an Xbox controller, and both of them work as expected.

  • For Photino project: I try to load the https://gamepad-tester.com/ site instead of the local HTML file.
    image
    image

  • For WinForms project: With Edge WebView2 Runtime 108 and SDK: 1.0.1549-prereleaseimage

Also as you mentioned in 114, Gamepad stop using after connected. I also tested it (simply test the buttons), but it works normally.
There might be some different setting or configuration in the workaround. Still need extra details to target the issue. Thanks.

@RonenNess
Copy link

Hi @ElyssaJyu thank you for checking!

This is very strange because the reason I even tested it was some of my users complained it stopped working for them so I know there are at least few people other then me experiencing this.

Do you have the same webview2 the rest of us have distributed with windows updates or maybe you have internal dev version that is not out yet? Is there a way for me to check if I have the same version as you?

Thanks :)

@ElyssaJyu
Copy link

Also try Photino project with load local HTML file: works as expected and show a "CONNECTED" alert.
image

@ElyssaJyu
Copy link

Hi @RonenNess
Please try to update the latest version. WebView2. And for SDK, I thought we use the same.
In case, could you check what version of WebView2 runtime you use currently?

@RonenNess
Copy link

Hi @ElyssaJyu
This is my WebView2 runtime version:
image

108.0.1462.54

Is this what you have?

@ElyssaJyu
Copy link

It's the same one I have and use. It's the latest version. Does the project work now?

@RonenNess
Copy link

Nope doesn't work. And I even reinstalled WebView.
What windows version you have? Which gamepad model you used? Maybe the difference is there..

If it was just me I'd say maybe something is just messed up with my PC, but as I said my players report gamepad suddenly stopped working for them too + there's @abiliaorg here that report something similar..

@abiliaorg can you test too and tell us if it works for you now? You seem to have older webview version which is interesting, but you have windows 10 like me.

@ElyssaJyu
Copy link

ElyssaJyu commented Dec 22, 2022

I don't think the Windows version or gamepad model does matter. In case, you can update the windows to Win11.
Please provide some details about situation of the running projects on your PC. It might be easier to target the issue. :)

Nope doesn't work. And I even reinstalled WebView.

Could you launch the WinForms project? Is the running project display the window with gamepad-test site? Could you check the webview2 process exist when running project?
image

@RonenNess
Copy link

Nice try Microsoft I'm not gonna update to windows11 just for that! :P
I might try later with vm but that will take some time to setup.

Anyway two things:

  1. As you can see you have different webview2 name than mine.
  2. Why do I have so many of them? Do you have more outside the crop or not? What happens when you extend the webview exe service (I can't extend them as you can see)
    image

Looks like something is different between us. Are you sure the version you saw in your application management is the runtime you actually use?

I also tried to open dev tools and ran navigator.getGamepads(), return 4 nulls (in chrome one of them is the gamepad).

btw here are additional details about my gamepad as windows recognize it:
image

image

@ElyssaJyu
Copy link

For webview2, it seems we are with the same version, and I just collapsed all before.
image

Is the running project display the window with gamepad-test site? Your screenshot shows that webview2 has been initialed and launching. The site should be loaded on the window as expected.
image
Also, you can see my test gamepad modal on the previous screenshot. It's Xbox Wireless Controller.

@RonenNess
Copy link

I found something interesting, there seems to be a problem with Edge itself.

Up until now I tested the gamepad either with chrome / firefox or WebView, just now I realized I never actually tested gamepad with Edge browser. So I did, and it doesn't work:

image

I then checked on a laptop that has older Edge version and tested - it worked:

image

So I updated that laptop Edge to latest version and it stopped working just like on my other computer.

Edge update from 107 to 108 seems to break gamepad

Can you check your Edge browser version? Is it possible that you have WebView 108 like me, but Edge version 107?

@ElyssaJyu
Copy link

ElyssaJyu commented Dec 22, 2022

Actually, my Edge version is 108. I tested on Edge browser again. Also tried with Chrome, it works.
image
image
Above screenshot, you can see the controller is displayed as player 3.

Please check your controller connection on PC or laptop. Sometimes it's unstable and will lose connection. (I have tried multiple controllers. One of them connects is not stable. Need reconnects)
image

It might be more related to Xbox controller Edge connection issue. I can check it with our related team. But perhaps, you can get Xbox support from website or find Xbox topic on GitHub, it might be quicker to target the issue for you.
Please let me know if there is remaining issue I can help. Thanks

@RonenNess
Copy link

RonenNess commented Dec 22, 2022

Hi @ElyssaJyu

I'm sorry but this is absolutely NOT an xbox controller issue.

  1. It works on every single browser in existence except for Edge.
  2. It literally worked on older Edge and the moment I updated version it stopped working while still working on other browsers (I had it side by side with Chrome, guess which one worked?).
  3. It stopped working for me and at few other people who contacted me + the one who opened this issue.
  4. This happened on two of my machines, not just one.

"it works for me so there's no bug" is not a serious response to this condition... even if this issue is with a specific xbox model and not all controllers - its still a bug with Edge support of a specific model. Lets find out why.

We need to continue and isolate differences until we nail it but "it works for me bye" is not a valid way to close this.

What is your exact Edge version? Windows version? X64? home edition? I can upload some Edge dlls to compare them?
Plenty of things to do.

Also maybe you can point me to some logs I can upload? tests to run? we only just scratched the surface in term of tests.

Edit: please do add the xbox related team on this as well so they can take a look too, but I don't think the issue is just with xbox I just don't have other controllers to test.

@RonenNess
Copy link

@ElyssaJyu
Here, I don't know how it can be any clearer than this there's a bug with Edge:

https://youtu.be/cLoKnvjO9R0

To be clear:

  1. The edge window was focused the whole time.
  2. In the middle I disconnected, you can see it lose the controller on chrome too, then I connected again and chrome immediately picks it up (as soon as I move the stick) while Edge doesn't.

Really don't know what else to say. I can provide any info you need just let me know what.

@ElyssaJyu
Copy link

@RonenNess. My previous response might cause some misunderstanding. Really sorry for that. Definitely, I don't mean that "it works for me so there's no bug".
The reason I guess it might be Xbox controller connection issue is that Chrome and Edge browser work or don't work at the same time when I try it. That's why I guess the possible issue might be a connection issue. BUT, from your tests, it shows that I have the wrong guess, it's not only an Xbox connection issue.

I have the same Edge version and WebView2 version with your setting. I have been checking it on different device, might need time to figure the difference.
Sorry this issue stopping your working. I am checking the change between Edge 107 and Edge 108 and will reach out Edge team and Xbox team for further investigation.

@ElyssaJyu
Copy link

Lets find the differences.

  • we have the same edge version 108.01462.54 (not work for you, but 107 works)
  • what's your window version?
  • Does your controller wire or wireless?

@ElyssaJyu ElyssaJyu added the tracked We are tracking this work internally. label Dec 22, 2022
@ElyssaJyu
Copy link

Edge is not detecting gamepads/controllers, after updating Edge version. I tagged as "tracked", so we can track it internally. We are aware of this and currently investigating. I will let you know the update as soon as possible.

@RonenNess
Copy link

Hi @ElyssaJyu sorry for the somewhat aggressive response I got the wrong idea from the suggestion to contact xbox.

So just to make sure - do you need additional info from me or did you manage to reproduce the issue on your end?

If there's something I can assist with please let me know :)

Got windows 10 home edition and wired controller btw.

@ElyssaJyu
Copy link

ElyssaJyu commented Dec 22, 2022

I find that our internal related gamepad team has be aware of this issue and working on it. (Also, I have described your issue to them.) I'm not sure when the fix can be released, but our engineers do aware of it. Also, I have followed the issue, and will let you know when it has been resolved.

@ElyssaJyu
Copy link

Hi @RonenNess, What's your gamepad PID/VID pair? It might help the team to resolve the issue.

@RonenNess
Copy link

Hi @ElyssaJyu this is the information I have in device manager events log, I think it contains what you need:

Device USB\ VID_20D6&PID_2001 \0000010186E85D0F was configured.

Driver Name: dc1-controller.inf
Class Guid: {05f5cfe2-4733-4950-a6bb-07aad01a3a84}
Driver Date: 02/10/2022
Driver Version: 10.0.19041.1566
Driver Provider: Microsoft
Driver Section: XboxOneController
Driver Rank: 0xFF2000
Matching Device Id: USB\MS_COMP_XGIP10
Outranked Drivers:
Device Updated: false
Parent Device: USB\ROOT_HUB30\4&1148bc98&0&0

@ElyssaJyu
Copy link

Thanks. I have provided to the team. We are working on it.

@abiliaorg
Copy link
Author

abiliaorg commented Dec 23, 2022

Hello @abiliaorg,

Thanks for your bug report. I've assigned this to a dev that can best try to replicate the issue and follow up on this.

Thanks @ElyssaJyu and everyone.
I use WPF and I started from the sample code provided, and visited https://gamepad-tester.com/. The gamepad is recognized and works if I keep the developer tools window opened and focused. When i focus on the webview, the gamepad is not working.

@ElyssaJyu
Copy link

Hi @abiliaorg, could you provide the WebView2 version and your gamepad PID/VID pair? In case, could you help us try open https://gamepad-tester.com/ on edge browser to test whether the gamepad can be recognized? It will help us to fix the issue. Thanks.

@RonenNess
Copy link

Any news about this? Anything I can help with?
Thanks

@ElyssaJyu
Copy link

We are still working on this issue, but it might take a while because of the holiday break. But I will let you get the update as soon as possible.

@RonenNess
Copy link

Bump - any news / estimation?
Thanks :)

@ElyssaJyu
Copy link

@RonenNess We have already had an idea on how to resolve the issue. I will let you know when we have made progress on this.

@ElyssaJyu
Copy link

@RonenNess Hi, the fix for that issue just landed in Edge 112.0.1689.0 (Official build) canary (64-bit). Could you try it out to see whether it works? Thanks.

@novac42 novac42 added the status-circle back Check back after requesting general information. label Feb 20, 2023
@RonenNess
Copy link

Hi @ElyssaJyu

It looks like I can't get the 112 update at the moment, maybe it has a region-based rollout and it hasn't reach me yet.
image

I will try again in few days and see if I can update and if it fixed the issue.
Thanks! :)

@mikeduglas
Copy link

mikeduglas commented Feb 20, 2023 via email

@RonenNess
Copy link

Downloaded canary version:
Version 112.0.1690.0 (Official build) canary (32-bit)

Can confirm the xbox controller works in the bworser.
The WebView still don't work but I guess the Canary version installer didn't update its dlls.

Is there an easy way to test the WebView as well?
Thanks! :)

@mikeduglas
Copy link

You can also reverse the behavior to use the most unstable: Canary > Dev > Beta > WV2 Runtime.
To reverse the order, you can set the WEBVIEW2_RELEASE_CHANNEL_PREFERENCE environment variable to 1, using Environment.SetEnvironmentVariable.

@RonenNess
Copy link

I tried adding Environment.SetEnvironmentVariable("WEBVIEW2_RELEASE_CHANNEL_PREFERENCE", "1"); before setting up the WebView window but nothing changed. Also tried setting the environment variable in system properties and not via code and nothing changed.

Not sure if its an indicator but when I run the program and check in task manager I see the old version:
image

@mikeduglas
Copy link

mikeduglas commented Feb 20, 2023 via email

@ElyssaJyu
Copy link

ElyssaJyu commented Feb 21, 2023

Thanks @mikeduglas's reference and help.
Hi @RonenNess, it's glad to hear Edge Canary channel works for you. Canary channel is a preview channel. You could try the latest prerelease version The release version will land in few weeks. release note
I will update with you when it's ready. Thanks

@ElyssaJyu
Copy link

Hey @RonenNess, please update WebView2 to 1.0.1724-prerelease. Could you confirm whether the Xbox controller works? Thanks

@novac42
Copy link
Contributor

novac42 commented Apr 13, 2023

@RonenNess Closing this issue, unless the latest prerelease still doesn't work. If that's the case you can reopen the issue and let us know. Thanks!

@novac42 novac42 closed this as completed Apr 13, 2023
@RonenNess
Copy link

Hey @RonenNess, please update WebView2 to 1.0.1724-prerelease. Could you confirm whether the Xbox controller works? Thanks

Hi sorry for not replying, I updated Edge to latest rebuilt the application (not sure if was necessary) and gamepad works in webview.

Thanks :) if the issue somehow returns I'll let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status-circle back Check back after requesting general information. tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

9 participants