Jump to content

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) {

I would really appreciate any help on this! Thanks!

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

  • 4 weeks later...
  • 3 weeks later...
  • 3 months later...

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: "",
    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: ""
zlib: "1.2.11"
__proto__: Object


Link to comment
Share on other sites

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.
  _this.__lastOffsetX = offsetX;
else if(Math.abs(_this.__lastOffsetX - offsetX) > 100) {

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

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.


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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...