Babylon.js: Exception thrown in Firefox when joystick / flight stick is connected

Created on 13 Apr 2017  路  3Comments  路  Source: BabylonJS/Babylon.js

In Firefox 52 for Windows, with a joystick (gamepad) connected to the PC (but not in use!), none of the BabylonJS demos will run correctly. An exception in thrown here:

        ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
            if (this.gamepad) {
                var camera = this.camera;
                var RSValues = this.gamepad.rightStick;
                if (RSValues.x != 0) {

TypeError: RSValues is undefined

It's worth noting that the user (me) wasn't attempting to use or test anything gamepad-related at the time. In fact I didn't even remember I had a gamepad-ish device connected until I dug into the un-minified version of this error. I have a flight stick connected (with no separate "left" and "right" sticks on it, just a single large stick). In Firefox, with this device connected, it looks like gamepad.leftStick is valid, but gamepad.rightStick is undefined. The mere passive existence of the joystick is enough to break all of BabylonJS in Firefox. I guess other browsers aren't broken because of possible gamepad API differences between browsers, or something.

Anyway, can BabylonJS be more tolerant of Firefox's gamepad quirks here?

bug

Most helpful comment

Thanks for the clarification. I've added a fix for your case.

All 3 comments

Hello! I don't reproduce on Firefox 53 running on Windows 10. For instance, this demo works great: http://www.babylonjs.com/demos/retail/ and I can move using a Xbox 360 controller.

Can you please tell us more about your platform:

  • exact version of Firefox
  • OS version
  • which controller you're using
  • a link to one our playground or specific demo of our homepage which fails

Yeah, unfortunately a typical Xbox controller doesn't reproduce this one. The system I found this on has a "CH Products Fighterstick USB" connected to it. This thing has only a single main stick on it, and so Firefox has decided that this.gamepad.leftStick should be populated but this.gamepad.rightStick should be left undefined.

This may be borderline "bug in Firefox" territory, but it has a bad consequence for BabylonJS. Almost every demo and sample is completely broken, even if the user hasn't touched the stick. By "completely broken" I mean uncaught exception thrown during initialization, resulting in blank screen before the user has a chance to interact.

I see Firefox updated from 52 to 53 since I last tried this. I'll test it with 53 tomorrow.

chproductsfighterstickusb

Thanks for the clarification. I've added a fix for your case.

Was this page helpful?
0 / 5 - 0 ratings