WebGL Cursor.LockState bug

I’ve been trying to get around this annoying bug for two days now and it’s driving me crazy. So I have a simple code that rotates a camera with the mouse, and moves forwards and backwards with the mouse wheel. Here’s my code:

void Start() {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }
    void Update () {
        RotationX = RotationX + Input.GetAxisRaw ("Mouse X") * MouseAcc * Time.deltaTime;
        RotationY = RotationY + Input.GetAxisRaw ("Mouse Y") * MouseAcc * Time.deltaTime;
        RotationY = Mathf.Clamp (RotationY, RotationMinMax.x, RotationMinMax.y);
        transform.rotation = Quaternion.Euler (-RotationY, RotationX, 0);
    
    
        if (Input.GetAxis("Mouse ScrollWheel") != 0) {
            T = 0;
            DirTo = transform.forward;
            Dir = Input.GetAxis("Mouse ScrollWheel") / Mathf.Abs (Input.GetAxis("Mouse ScrollWheel"));
            StopAllCoroutines ();
            MoveCoroutine = StartCoroutine (MoveAbit());
        }
    
        chc.Move (Velocity * WalkSpeed * Time.deltaTime);
    }
    IEnumerator MoveAbit() {
        while (T < 0.15f) {
            Velocity = DirTo.normalized* Mathf.Clamp (Dir, -1, 1);
            T+=Time.deltaTime;
            yield return new WaitForSeconds (Time.deltaTime);
        }
        T = 0;
        Velocity = Vector3.zero;
    }
}

chc is my Character Controller btw.
In the editor it works exactly as it should. When I build it and run it google Chrome though, it behaves strange. After a lot of testing, I narrowed down the problem to the Cursor.LockState . If this is locked, the mouse scroll somehow affects the X and Y axis of the mouse. When I move the wheel, and after that move the mouse, the camera is rotated not slightly as it should by the X or Y axis, but instead it rotates as if the mouse scroll delta is added to the X and Y axis. It’s very strange and erratic behaviour.
When the Cursor is not locked, this problem doesn’t occur, but I need it locked because if it’s not, when the mouse goes out of the window you cannot move anymore.
And btw, I’ve tried to remove the part of the code that moves the camera with the scroll, and it still does the same. So event if I don’t use the scroll in my script, the camera is still affected by the scroll.
Anyway it’s a weird bug, I really hope someone has a workaround or a fix. Thank you!

Actually now I tried it with the standard First Person Character Controller and it still does the same. If I move the scroll, and then move the mouse, the view shifts instantly from one position to another. So my code has actually nothing to do with the problem, I turned it off and still get this issue.

Bump!
Has anybody been able to find a solution to this?

Similar problem here, noticed this happening with scroll-wheel, but recently Chrome is working even worse with locked mouse and transform rotation. All other browsers are fine but Windows + Chrome ends up glitching when rotating a camera transform and only when mouse is locked.

Tested Unity versions - 5.4.5 and 2017.2
Chrome versions that are showing this - 62, 63

Same here, after updating to Chrome 63 almost every WebGL game have this issue, mouse view randomly snaps to a random rotation.
Here is a short gif showing the bug: http://vvcap.com/h4W5xABi2xZ

I have a similar problem with Chrome.
My script rotate the camera if you hold the left mouse button - and the button seems to stay pressed for the rotation.

I have reported this bug in March 2017 and it’s still the same, some information for you 3 bug in Chrome/Canary/Firefox

I will create a big post soon with all these bug present and still not fixed.

We have to wait again and again …

Same thing here, it seems like after I move the mouse enough, there is a sudden jump in mouse input, even if I am not using the mouse wheel.

I’m experiencing the same issue with the cursor warping. Something interesting to note is that the issue doesn’t seem to occur if you set it to use WebAssembly.

it seems to happen to me whatever I do for webgl once published on the internet, running locally its fine.

I realise this is an old thread - but ive spend DAYS trying to fix this