Closed Bug 1287104 Opened 8 years ago Closed 8 years ago

PointerLock demo can't be enabled after changing focus

Categories

(Web Compatibility :: Site Reports, defect)

Firefox 47
defect
Not set
normal

Tracking

(firefox48 wontfix, firefox49 wontfix, firefox50 fix-optional)

RESOLVED WORKSFORME
Tracking Status
firefox48 --- wontfix
firefox49 --- wontfix
firefox50 --- fix-optional

People

(Reporter: sbadau, Unassigned)

References

(Blocks 1 open bug, )

Details

(Whiteboard: [needsdiagnosis] [country-all])

[Affected versions]:
- Firefox 47 RC
- Firefox 48 beta 7
- Firefox Developer Edition 49.0a2
- Nightly 50.0a1

[Affected platforms]:
Windows 10
Mac OS X 10.10
Ubuntu 15.04


[Steps to reproduce]:
1. Launch the latest Nightly
2. Navigate to this pointer lock demo:
http://threejs.org/examples/misc_controls_pointerlock.html
3. Click the demo's content to enter PointerLock mode
4. Change focus to another application by using the keyboard shortcut ALT+TAB
5. Using the keyboard shortcut ALT+TAB, return back to the Nightly window
6. Click the demo's content to enter PointerLock mode

[Expected result]:
- In step 6, the pointer should be unlocked, and clicking back on the demo should re-enable the pointer lock.

[Actual result]:
- In step 6, the pointer seems unlocked but clicking the demo does nothing (the demo freezed.) 

[Regression range]:
- Not a recent regression (reproducible also on FF 47), I will investigate more and post the results as soon as possible.
Blocks: pointer-lock
This is because the demo has some specific code for Firefox. It request fullscreen, and then request pointer lock inside handler of fullscreenchange event.

However, when you use Alt+Tab to escape from pointer lock, you wouldn't exit fullscreen, and in that case, further click wouldn't trigger fullscreenchange event (because you're already in fullscreen), and consequently, requestPointerLock would not be called.
So given my comment 1, I think in this demo, everything works as expected on the browser side. Moving to Tech Evangelism.

The demo tries to request fullscreen on Firefox probably because that would remove the annoying permission request popup. But since Firefox 50, we no longer have that popup either. We can probably ask them to remove the Firefox-specific code then.
Component: DOM → Desktop
Product: Core → Tech Evangelism
Version: 50 Branch → Firefox 50
Spoofing the user agent to anything that doesn't include 'Firefox' causes it to go around in circles. 

instructions.addEventListener( 'click', function ( event ) {

  instructions.style.display = 'none';

  // Ask the browser to lock the pointer
  element.requestPointerLock = element.requestPointerLock || element.mozRequestPointerLock || element.webkitRequestPointerLock;

  if ( /Firefox/i.test( navigator.userAgent ) ) {

    var fullscreenchange = function ( event ) {

      if ( document.fullscreenElement === element || document.mozFullscreenElement === element || document.mozFullScreenElement === element ) {

        document.removeEventListener( 'fullscreenchange', fullscreenchange );
        document.removeEventListener( 'mozfullscreenchange', fullscreenchange );

        element.requestPointerLock();
      }

    };

    document.addEventListener( 'fullscreenchange', fullscreenchange, false );
    document.addEventListener( 'mozfullscreenchange', fullscreenchange, false );

    element.requestFullscreen = element.requestFullscreen || element.mozRequestFullscreen || element.mozRequestFullScreen || element.webkitRequestFullscreen;

    element.requestFullscreen();

  } else {

    element.requestPointerLock();

  }

}, false );

Switching to needsdiagnosis.
Whiteboard: [needsdiagnosis] [country-all]
Given that this is not a new regression, and the problem is not in our codebase, I would consider this as a fix-optional for all affected versions so far.
Version: Firefox 50 → Firefox 47
(In reply to Adam Stevenson from comment #3)
> Spoofing the user agent to anything that doesn't include 'Firefox' causes it
> to go around in circles. 

What do you mean by "go around in circles"?
Flags: needinfo?(astevenson)
When I was testing the other day the view would spin uncontrollably along the x axis if the user agent was spoofed to something like Chrome or Edge. Testing it again today, it still is uncontrollable but it pans up along the y axis and gets stuck looking up.

Basically to say, it doesn't work properly by simply switching the user agent.
Flags: needinfo?(astevenson)
The demo has been updated to not request fullscreen anymore -- it works as I would expect it to. (And there's no more if(Firefox){} junk anymore).
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → WORKSFORME
Product: Tech Evangelism → Web Compatibility
You need to log in before you can comment on or make changes to this bug.