Closed Bug 1522089 Opened 6 years ago Closed 6 years ago

Youtube - space bar doesn't pause the video (at all)

Categories

(Web Compatibility :: Site Reports, defect, P1)

Firefox 66
defect

Tracking

(firefox65blocking verified, firefox66 verified)

VERIFIED FIXED
Tracking Status
firefox65 blocking verified
firefox66 --- verified

People

(Reporter: kevinberaca, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0

Steps to reproduce:

  1. Open youtube.com
  2. Click on any video
  3. Press Space

Actual results:

The video kept playing, showing the play button animation instead of pausing.

It's like it registers two presses, one for pause and one to play again without ever pausing the video.

The only way to pause the video now is to click the video itself or the pause button in the bottom left corner.

Expected results:

The video should have been paused.

I also tried this in safe mode, to make sure no add-ons were interfering. Of course, this issue doesn't happen in Chrome, but I'm not putting on my tin foil hat just yet.

I can reproduce this issue with Firefox 64.0.2 (64-bit) on Windows 10, 64bit.

As I can reproduce this, I am marking this as new.

Please note that various issues have been reported recently with Youtube video playback all of which have space key in common. I am not sure if all of these are dupe of each other.

Please see also Bug 1491256 and Bug 1481400

Status: UNCONFIRMED → NEW
Has STR: --- → yes
QA Whiteboard: [triagemonth-2019-01]
Component: Untriaged → Event Handling
Ever confirmed: true
Product: Firefox → Core
See Also: → 1481400, 1491256

Thank you for pointing out those other bugs.

I also saw them before posting this, however there's one major difference in this case which sets it apart and, in my opinion, makes this more impactful. They both require clicking another thing before pressing the space bar i.e. play/pause button or mute/volume button. Needing the video to be focused in order for the space bar to play/pause has been a limitation for a long time, which somewhat makes sense, but this just doesn't.

In this case, the bug just happens, without clicking anything else after loading a video.

Hopefully the issue is easy to fix.

ah sorry couldn't find it cuz v1tesse wrote "space bar" but I searched for "spacebar" (1 word). Sorry for the duplicate. Hoping for a hotfix this week.

I can not reproduce on trunk(m-c)build. But, I can reproduce release build and/or late beta.

Regression window(in 64 RC cycle):
https://hg.mozilla.org/releases/mozilla-release/pushloghtml?fromchange=f040763d99ad0cc888b453da4de53422593810dd&tochange=321f1fb3b41f81d84adef4a7ba1fccf8f81f8364

Regressed by : 5856e2411504 Masayuki Nakano — Bug 1510985 - Remove Event.returnValue temporarily in 64. r=smaug a=jcristau

Regression window(in 65 Beta cycle):
https://hg.mozilla.org/releases/mozilla-beta/pushloghtml?fromchange=21ebd471d7a645f5b501abbb194f4696195dae63&tochange=e71504cbe594bbda84395ce67c323adc0b855b23

Regressed by: 6881825b5cd7 Masayuki Nakano — Bug 1520756 - Disable Window.event, Event.returnValue and setting keyCode and charCode of "keypress" events to same value. r=smaug, a=RyanVM

Blocks: 1510985, 1520756

I do experience this bug too in Firefox 64.0.2 (64-bit) on Windows 10, 64bit.

I do not think this is related to YouTube because spacebar is well handled in Edge or Chrome.

So there is a fix for this already in Nightly it seems (as it's working as intended there)? can we get that fix into Beta and into FF release asap?

(In reply to Daniel from comment #7)

So there is a fix for this already in Nightly it seems (as it's working as
intended there)? can we get that fix into Beta and into FF release asap?

Already fix by Bug 1452569 in m-c cycle, but (partially?)bucked it out in 64.0RC and 65.0b12 cycle.

@masayuki, can you please look into this?

Flags: needinfo?(masayuki)

"m-c cycle" ? Sorry I don't understand that yet. So what's ETA for it to come to Beta, and release?

Tom, can you find anything related to returnValue in the spacebar handling code?

Flags: needinfo?(twisniewski)
Severity: normal → critical
Priority: -- → P1

If I remove the following keydown listener from <html>, I can get the bug to reproduce in Chrome (going down the rabbit hole, could be something else...):

handleCapturedKeydownEvent_: function(a) {
  if (32 == a.keyCode && !this.keyboardInUse_)
  this.onKeyDownEvent_(a)
},
onKeyDownEvent_: function(a) {
  if (!this.ignoreKeyEvent_(a) && (191 == a.keyCode && (a.shiftKey || a.metaKey ? (this.openHotkeyDialog_(),
        Y9(a.keyCode, a.shiftKey)) : (this.focusSearchBox_(),
        a.preventDefault())),
      !a.metaKey))
    switch (a.keyCode) {
      case 9:
        this.keyboardInUse_ = !0;
        break;
      case 32:
        K("global_spacebar_pause") && !this.keyboardInUse_ && (a.preventDefault(),
          this.passEventToPlayer_(a));
        break;
      case 84:
        this.toggleTheaterMode_(a.keyCode, a.shiftKey);
        break;
      case 73:
        this.toggleMiniplayer_(a.keyCode, a.shiftKey);
        break;
      case 27:
        if (this.closeMiniplayer_(a.keyCode, a.shiftKey))
          break;
      default:
        this.passEventToPlayer_(a)
    }
},

Daniel, does this still reproduce for you in release 64 (in a new profile)?

Oddly, I was able to reproduce and now I can't (anywhere...). Wondering if YouTube rolled back an update or something.

Flags: needinfo?(danielboontje)

Reaching out to Google about this via partner mailing list.

(In reply to Mike Taylor [:miketaylr] from comment #13)

Daniel, does this still reproduce for you in release 64 (in a new profile)?

I can still reproduce with release 64 on Windows 10(64-bit) and on Linux x86_64

I also tested a new profile in FF 64.0.2 and noticed different behaviors:
Under my initial testing conditions: open youtube, load on a video, press space - it was the exact same, pressing space didn't pause the video and it showed the "play" animation (like every time it was unpaused instead of pausing).

Then, I tried a few different things:

  • Clicking right next to the video (white space) made the spacebar work as intended - pause or unpause on pressing it.

  • Clicking the video itself reinstated the previous (buggy) behavior and it's the same as refreshing the page.

  • Clicking the play/pause button on the bottom-left and afterwards pressing space registers it but only for a brief moment. If the video is playing, it pauses for a split second, then continues on playing. Same if it's paused - it plays the video a little and stays paused. This may be a totally unrelated issue and may affect less people since I'm guessing most of us are used to just clicking the video itself to pause/unpause when not pressing space.

Yes, I do see returnValue being set to false on a keydown event when I press the spacebar (and it doesn't work).

Here's the stack trace:

  g.Nr https://www.youtube.com/yts/jsbin/player_ias-vflH-Ze7P/en_US/base.js:7680:9
  g.h.rw https://www.youtube.com/yts/jsbin/player_ias-vflH-Ze7P/en_US/base.js:49367:48
  Ta/< https://www.youtube.com/yts/jsbin/player_ias-vflH-Ze7P/en_US/base.js:323:20

g.Nr is indeed where the returnValue is set to false. It looks like a general-purpose "prevent default on this event" function:

    g.Nr = function(a) {
        a = a || window.event;
        a.returnValue = !1;
        a.preventDefault && a.preventDefault()
    };

However, if I have it return early without preventing the default action, the spacebar still isn't working properly.

Flags: needinfo?(twisniewski)

Ah, I think I figured out the problem (though not the precise cause). Given the stacktrace in my previous comment, the g.h.rw function was some kind of key handler, so I made it return early without doing anything, which made the spacebar work properly again. Digging into that function a bit, I realized that it wasn't actually doing anything with the spacebar pausing functionality, save for this single line (the one the stack trace implicated):

(f || e && EU(this, c, a.shiftKey)) && g.Nr(a);

If I commented that line out, the spacebar worked as well. However, if I made that EU function return early as well, the spacebar didn't work. That means that EU is being called twice, once by this function, and once via some other means. And so I checked a stack trace for the other time that EU was being called, and saw this:

  EU https://www.youtube.com/yts/jsbin/player_ias-vflH-Ze7P/en_US/base.js:27934:1
  g.h.gr https://www.youtube.com/yts/jsbin/player_ias-vflH-Ze7P/en_US/base.js:50086:19
  g.h.WF https://www.youtube.com/yts/jsbin/player_ias-vflH-Ze7P/en_US/base.js:40423:14
  VB/a.o[b] https://www.youtube.com/yts/jsbin/player_ias-vflH-Ze7P/en_US/base.js:12985:20
  d.bindApi_/< https://www.youtube.com/yts/jsbin/desktop_polymer-vfl9gefLf/desktop_polymer.js:9832:91
  passEventToPlayer_/< https://www.youtube.com/yts/jsbin/desktop_polymer-vfl9gefLf/desktop_polymer.js:14143:390
  d.nextStep_ https://www.youtube.com/yts/jsbin/desktop_polymer-vfl9gefLf/desktop_polymer.js:475:66
  d.next_ https://www.youtube.com/yts/jsbin/desktop_polymer-vfl9gefLf/desktop_polymer.js:470:210
  wa/this.next https://www.youtube.com/yts/jsbin/desktop_polymer-vfl9gefLf/desktop_polymer.js:476:49
  b https://www.youtube.com/yts/jsbin/desktop_polymer-vfl9gefLf/desktop_polymer.js:479:89

So what's happening is that EU is the function that actually handles the spacebar pausing functionality, and it's being called by two keydown event handlers, one somewhere in polymer, and the other being the g.NR function in my original stace trace.

I've managed to deduce that there are five keydown handlers on the HTMLDocument (disabling them makes the spacebar do nothing at all). However, three of them go through that polymer script (two of them through webcomponents_lite.js, and one apparently directly). So I'll have to dig around some more when my head's a bit clearer.

But the fundemental problem is that EU is being called twice for the same keydown event, which is why we're seeing the results we are.

ni? Dennis to take over for now, as it's end-of-day for me. Good hunting, Dennis!

Flags: needinfo?(dschubert)
Flags: needinfo?(masayuki)

Mike yes it reproduces with a new profile in 64 release.

Flags: needinfo?(danielboontje)

Hey Tom, I tried multiple operating systems, multiple profiles, multiple Firefox versions, multiple countries via VPNs, but I am unfortunately unable to reproduce. So unfortunately, I am unable to help out with diagnosis here... :(

Flags: needinfo?(dschubert) → needinfo?(twisniewski)

I'll keep poking at it, thanks for trying!

Flags: needinfo?(twisniewski)

I've confirmed their code seems to be adding listeners intended for the event capturing phase, as two of the handlers I see being attached are named "handleCapturedKeydownEvent_" and "onCaptureKeyDown" in their desktop_polymer.js. However, I don't see that file referencing eventPhase, so it's possible they just are processing events not meant for the capture phase. (I've let Google know on our mailing list thread).

Google just replied that they have rolled out a fix, and that they will take care to not reproduce the problem when they change back to using the event-capturing phase again in a subsequent YouTube release.

I've confirmed that the spacebar is now working properly for me.

Can the others who were having the spacebar problem clear their cache and try again, to confirm that it's fixed?

Flags: needinfo?(kevinberaca)

It looks like that did the trick. Space is working properly for me too.
I'm glad it could be fixed in such a short time.

Thank you to all those involved.

Flags: needinfo?(kevinberaca)

I can't test yet, will test in few days. What means a "subsequent YouTube release" ?

Resolving this as fixed based on comment 26. Adam, I updated the product/comp on this as Tech Evangelism -> Desktop. Hope that's inline with how you update the webcompat bugs.

Status: NEW → RESOLVED
Closed: 6 years ago
Component: Event Handling → Desktop
Flags: needinfo?(astevenson)
Product: Core → Tech Evangelism
Resolution: --- → FIXED
Target Milestone: --- → Jan
Version: 64 Branch → Firefox 66

Also https://redd.it/ajax8u

Space stops working on YouTube : waterfox

– with Waterfox 56.2.6 (Waterfox 56.0 was based on Firefox 56.0.2).

(In reply to Ritu Kothari (:ritu) from comment #28)

Resolving this as fixed based on comment 26. Adam, I updated the product/comp on this as Tech Evangelism -> Desktop. Hope that's inline with how you update the webcompat bugs.

Yep, that's fine, thanks.

Flags: needinfo?(astevenson)
Product: Tech Evangelism → Web Compatibility

I still have this issue on 76.0.1

This only happens if you click the play/pause button (bottom left) first and then press space, which is a much older issue that was maybe fixed at one point but it has reoccurred - bug 1481400.

Clicking a button i.e. play or mute etc. and then pressing space makes space trigger two actions - the action of the previously-pressed button and play/pause. So if play was the button, then it pauses (button action) AND it immediately starts playing (normal action). If you clicked mute, then it unmutes/mutes AND play/pauses. See the previously referenced Bug 1491256.

If you just load a video and press space, there's no issue, so if you encounter this, then it's probably because you previously clicked the play/pause button, so a temporary fix is to just stop clicking on the actual play/pause button and click on the video image itself for space to work properly.

You need to log in before you can comment on or make changes to this bug.