Bug 192530 - [GStreamer] HTMLMediaElement::m_player->paused is always true while video is playing
Summary: [GStreamer] HTMLMediaElement::m_player->paused is always true while video is ...
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-08 13:57 PST by Michael Catanzaro
Modified: 2019-02-15 09:47 PST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Catanzaro 2018-12-08 13:57:49 PST
I was debugging why SleepDisablerGLib is broken currently. After getting a bit distracted by the inhibit portal being broken (separate bug, not our fault) I realized HTMLMediaElement is never creating SleepDisabler objects in the first place.

Turns out that when playing a YouTube video, HTMLMediaElement::shouldDisableSleep always returns early in this condition here:

    if (!m_player || m_player->paused() || loop())
        return SleepType::None;

because m_player->paused() is returning true. But this happens when the video is playing, not when it is paused. So yeah that's not good.
Comment 1 Michael Catanzaro 2018-12-08 14:03:20 PST
BTW I wonder if this state tracking issue is why YouTube videos often restart improperly when moused over.
Comment 2 Michael Catanzaro 2018-12-09 15:22:23 PST
Strangely it's not a recent regression, I tried bisecting this but found this to be the case as far back as the 2.20(!) branchpoint.
Comment 3 Alicia Boya García 2018-12-10 07:16:46 PST
Can you confirm if this affects the non-MSE media player?
Comment 4 Michael Catanzaro 2018-12-10 07:23:14 PST
I tried to disable the setting in MiniBrowser and noted that paused() was still returning true during playback, but I'm not sure if the setting really took effect or not.

Unfortunately I can't confirm outside my WebKit jhbuild because MSE is now required for YouTube video playback without H.264.
Comment 5 Alicia Boya García 2018-12-10 07:35:42 PST
(In reply to Michael Catanzaro from comment #4)
> I tried to disable the setting in MiniBrowser and noted that paused() was
> still returning true during playback, but I'm not sure if the setting really
> took effect or not.
> 
> Unfortunately I can't confirm outside my WebKit jhbuild because MSE is now
> required for YouTube video playback without H.264.

What about this one? https://www.w3schools.com/html/html5_video.asp
Comment 6 Michael Catanzaro 2018-12-10 10:37:17 PST
(In reply to Alicia Boya García from comment #5)
> What about this one? https://www.w3schools.com/html/html5_video.asp

OK that worked. The bug occurs the same with and without MSE.

P.S. Apparently I've never seen that part of Big Buck Bunny. It was traumatizing. :(
Comment 7 Philippe Normand 2019-02-15 08:53:55 PST
I can't reproduce this issue.

diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp
index 88eae188a0e..8d2f2d18379 100644
--- a/Source/WebCore/html/HTMLMediaElement.cpp
+++ b/Source/WebCore/html/HTMLMediaElement.cpp
@@ -6896,6 +6896,7 @@ HTMLMediaElement::SleepType HTMLMediaElement::shouldDisableSleep() const
 #if !PLATFORM(COCOA) && !PLATFORM(GTK) && !PLATFORM(WPE)
     return SleepType::None;
 #endif
+    WTFLogAlways("paused: %d", m_player->paused());
     if (!m_player || m_player->paused() || loop())
         return SleepType::None;


$ run-minibrowser --gtk https://www.w3schools.com/html/html5_video.asp
paused: 1
paused: 1
paused: 1
paused: 1
paused: 1
paused: 1

# ^ this is expected because autoplay is disabled for this element
# now let's press play.


paused: 0
paused: 0
# Playback about to end
paused: 1
paused: 1
# Done...
Comment 8 Michael Catanzaro 2019-02-15 09:47:00 PST
I can confirm this seems fixed, in both WebKit JHBuild and my personal JHBuild.

Now, HTMLMediaElement::updateSleepDisabling is not being called when paused/unpaused, which is bad, but I believe we have other bug reports for that.