☑ Newest version of Chrome causing issues with VR controllers

Hi,
I am having a strange kind of issue this morning. I make lots of HTC Vive apps which use the controllers. Published versions of these apps that were made a few days ago are working fine but when I try to publish them now (even without any changes) the controllers no longer work. There are no errors in the console so I am not sure why they are not working anymore. Launching from the editor works fine, its simply when published that the controllers don’t move.

For an example see

https://playcanvas.com/project/419451/overview/htc-vive-conveyor

launch from editor works fine, published doesn’t. whatever is stopping the published version is new because older published versions work fine as well.

I just tested both launch and published builds for that project and the controllers work fine.

Hi Dave,
It looks like the latest version of Chrome experimental might be the cause

I tracked it down to this line of code

var gamepads = navigator.getGamepads();

In the editor launch this object contains 2 controllers and 2 undefined
In the published launch this object contains 4 undefined.

If it’s not too much trouble I wouldn’t mind a second opinion that its the latest chrome thats causing it

my version is 55.0.2842.0

what I don’t get is why this line of code is producing two different results in the same browser?

UPDATE: looks like i am not the only one

UPDATE: I am wondering if it’s a bug in the new version of chrome and on secure https:// sites? I am waiting for someone on the forums to confirm that this is the case. But if it is why are older published versions working and newer ones not? Could something in the recent playcanvas changes caused a bug to surface?

Hi Dave,
Did you get chance to see my edits on the thread?

My best guess is that it’s some kind of cross-domain security issue which effects the latest version of chrome and it’s the recent changes to playcanvas publishing which is bringing it to light. Possible?

I don’t have time to test this at the moment, but my suspicion is that it is (Experimental) Chrome rather than PlayCanvas as the changes we’ve just made should reduce CORS problems.

You can use both the launch page and the published pages from https as well as http. Try changing that and see if one works?

Hi Dave,
Sadly no change, running the editor in https:// still works and running the published in http: doesn’t

So to summarise so far:

navigator.getGamepads()
Before the recent publishing changes it worked in both editor and published
After the playcanvas changes and after updating to the latest version of chrome it works in editor but not in published
Older published versions before the playcanvas changes work fine.
Other people besides playcanvas users are experiencing similar issues

Still pointing to a browser issue and CORS and I think that the playcanvas changes are simply throwing light on it.

The latest on the issue thread above has confirmed that it is recent changes to the security model in chrome experimental which is causing the gamepads not to work. However oddly testing seems to indicate it breaks http:// but works for https:// (it’s even effecting the sample demos on the webvr.info site). So at the moment I am stuck not being able to publish any new projects using vive controllers.

Published content runs over https, so it shall work?
And you can use https with launcher as well.

That’s the odd thing, it should work even better since the recent changes to publishing but in fact non of the recently published projects do??

Have you guys tried the latest version of chrome with recently published apps?

mmm…our logo comes from http on the loading screen, I wonder if that would invalidate the whole app security wise?

There is no such thing as “invalidate security” of a page.
One thing comes into my mind is where exactly .js files are served from, and if that is different domain and/or non-https, it might lead to that issue.
One way to check is to create very simple, minimal project that purely tries to detect if getGamepads works (not even using any libraries, just vanilla js), then do different options of serving files to verify which works and which doesn’t.

Hi Max,

I reduce it down to the smallest possible example.

The project

https://playcanvas.com/project/420077/overview/getgamepad-test

Was created by the blank project and simple dropping in the two scripts from the playcanvas webvr plugin

and a single script which on update does this

var pads = navigator.getGamepads();
console.log(pads);

then I launch the editor, click the screen and open the console. as soon as you press a button on the controllers you can see that the pads contain two gamepads 0 and 1

if you do exactly the same test with the published version you get no gamepads,

my version of chrome experimental is 55.0.2842.0 (64-bit)

If you believe this is bug with chrome, then it is good to use their bugtracking system to report bugs, as it is out of our scope.

the case with PlayCanvas is related but also a little different but you can mark it solved if you want. I will simply wait until it’s resolved one way or the other before publishing anything new.

But if you find that all PlayCanvas games using gamepads stops working with the next version of chrome you cannot say I didn’t warn you :slight_smile:

Hi Max,
It’s starting to look like it may be some kind of issue with the changes to the webvr spec and the existing webvr plugin for PlayCanvas.

It seems not all webvr applications on the internet are effected. For example in PlayCanvas the editor launched version is uneffected but the published versions are. Many of the webvr demos around the web are still working, Sketchfab site is still working. So it’s only certain sites that are effected including your own.

As I understand it the HMD has to be started and the controllers need to be moved or buttons pressed before the controllers appear in navigator.getgamepads() (that has certainly been the case in the past) so perhaps it’s something to do with the way the HMD is initialised on PlayCanvas which is preventing the getgamepads() from initializing.

So it appears that not all websites are initializing the environment the same way.

It’s possible that the next version of chrome experimental will take a step back but I doubt it, more likely people creating plugins like yourself will probably have to update their code to keep pace.

But I think the clue to sorting this problem is that the unpublished versions work but the published ones do not. So there has to be something different in how they run?

Only a week or so ago I noted a bug where code that reference app.graphicsDevice would work fine in the editor but not in the published version and only after changing it to this.app.graphicsDevice did it work in both. So perhaps it’s something like that hanging around in the webvr plugin scripts that might be the source of the issue.

Hey we just deployed a fix that was affecting gamepads not working on published apps - perhaps this fixes some of the issues you were facing?

Hi,
That’s great news but I am having difficulty getting into the site to test the changes. I keep getting security warning popping up complaining about the certificate and when I go into the editor it just constantly disconnects. It only seems to be happening on the current chrome experimental, normal chrome appears unaffected. Unfortunately I need the experimental version in order to test the gamepads on the HTC Vive.
:frowning:

as one door opens …

UPDATE: Managed to fix my certificate problem (out of date build of chrome exp) and the first test was successful ! going to test a few but its looking good…

ANOTHER UPDATE: Confirmed, gamepads are working fine now with published versions! Yea!
Thank you very much whoever figured out the problem :sunny: :smile: