srimshady

Pointer lock bug on Chrome with windows 10

Recommended Posts

Hello, I am getting a strange bug in chrome with the pointer lock API.  When using chrome on windows 10, the mouse will randomly move to a new location as I move the mouse around. I have repeated this bug on seperate machines. Works fine on firefox. Here's a play ground: https://playground.babylonjs.com/#H9FRSI#2. I removed the non chrome pointer lock stuff.

 

Pointerlock code for chrome: 

 

scene.onPointerDown = function (evt) {
  
    canvas.requestPointerLock();
      
};
   

I would really appreciate any help on this! Thanks!

Share this post


Link to post
Share on other sites

Hi, same here on all instances of Pointer Lock.  When trying to spin around 360 degrees, the camera angle will randomly snap back to start position.  I filed a problem report with the Chrome team, hopefully it will be resolved soon.

Share this post


Link to post
Share on other sites

The Windows 10 Fall Creators Update is rife with problems; this being one of them, although it could be argued that it really just exposed a problem with Chromium, since it's the only browser that is exhibiting this issue.

I've implemented a "solution" in my game which simply ignores the first mousemove event that moves in the opposite direction, thereby eliminating that big jump backwards in most circumstances. Such events are high enough in frequency that ignoring a few here and there is not noticeable. It's not 100% effective, but it's a huge improvement when the alternative is that your app is basically rendered unusable.

I know this doesn't help much when you're relying on Babylon's built-in input functionality, but one could use FreeCameraInputsManager, for instance, to register a new mouse input function to replace the old one.

Share this post


Link to post
Share on other sites

I'm not using babylon, it's absolutely a chrome issue. I don't have a system to test the issue on either. What do these bad values look like? Maybe there is a recognizable pattern (I'm sure you've checked though).

@erichlof: can you maybe link me to the bug report you filed? It's a pretty big issue for me too.

Share this post


Link to post
Share on other sites

i have the same issue ? any fix ?

i have chromium: "65.0.3325.146"

process.versions {
    http_parser: "2.7.0",
    node: "9.7.1",
    v8: "6.5.254.31",
    uv: "1.19.2",
    zlib: "1.2.11",
    …
}
ares: "1.13.0"
chromium: "65.0.3325.146"
cldr: "32.0"
http_parser: "2.7.0"
icu: "60.1"
modules: "59"
napi: "2"
nghttp2: "1.29.0"
node: "9.7.1"
node - webkit: "0.29.0"
nw: "0.29.0"
nw - commit - id: "40ba6a3-15b9f14-1b41b42-41dc8a9"
nw - flavor: "sdk"
openssl: "1.0.2n"
tz: "2017c"
unicode: "10.0"
uv: "1.19.2"
v8: "6.5.254.31"
zlib: "1.2.11"
__proto__: Object

aefef.thumb.png.cd34944a2aa0ec94cfc1ca05edc12216.png

Share this post


Link to post
Share on other sites

@jonforum
I'm not having any issues on "66.0.3359.139"

However, the bug is indeed annoying, and appears to happen with several hundred units at a time, before then going back to around previous values.
If you want a fix for the bug, (to make sure everything works for ppl who doesn't update their browsers 😛 )

Something like this should work;
Note; i set the max value the mouse can move before thinking it's a bug jump to 100, you can lower or increase this as needed, (not tested on bugged browser, but works fine on non-bugged).

// Fix for Chrome mouseMove "sudden jump" bug.
if(!_this.__lastOffsetX){
  _this.__lastOffsetX = offsetX;
}
else if(Math.abs(_this.__lastOffsetX - offsetX) > 100) {
  return;
}

if(!_this.__lastOffsetY){
  _this.__lastOffsetY = offsetY;
}
else if(Math.abs(_this.__lastOffsetY - offsetY) > 100) {
  return;
}

It should be placed inside the FreeCameraMouseInput's "_onMouseMove" function (see lines 112 - 128 in PG)
Or if you'd rather not edit babylon source, the entire function can be overwritten, simply copy the "BABYLON.FreeCameraMouseInput.prototype.attachControl" from the PG below and load in a JS file, after Babylon.js is loaded.

http://playground.babylonjs.com/#HTKXPC
 

It should eliminate the bug, but comes with a downside, moving the mouse very rapidly & far will trigger it aswell.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.