Closed Bug 1121692 Opened 9 years ago Closed 9 years ago

Excessive seeking renders YouTube unplayable

Categories

(Core :: Audio/Video, defect, P1)

x86_64
Windows 8.1
defect

Tracking

()

RESOLVED FIXED
mozilla38
Tracking Status
firefox36 --- fixed
firefox37 --- fixed
firefox38 --- fixed

People

(Reporter: cpearce, Assigned: bholley)

References

(Blocks 1 open bug)

Details

Attachments

(8 files)

I turned on media.mediasource.decoder-per-segment, and then loaded https://www.youtube.com/watch?v=Cm7mCmncbvA in Nightly. It played for a bit, and I switched to 1080p. Then I kept seeking a little bit ahead of the last buffered position while playing. Once playback reached the end and the media was fully buffered, I clicked the seek bar and scrubbed it back and forward over the timeline erratically and quickly to force excessive seeking. I did that for about 15 seconds. The frame being displayed was stuck at the "Peanuts hua sheng" frame. If I seek, the seek appears to work, and the displayed frame changes, but once I let go of the scrubber the frame changes back to the "Peanuts hua sheng" frame. I also can't play the video anymore; the play buttons don't do anything.

I don't know if this bug occurs with media.mediasource.decoder-per-segment not set.

I think the key here to repro the bug is the excessive scrubbing/seeking once the media is buffered.

Windows 8.1, Nightly 38.0a1 (2015-01-14).
Flags: needinfo?(bobbyholley)
Seems quite hard to reproduce; I've been trying and could not repro again.
I just reproduced this with a log and have it in a debugger. The MDSM is stuck in a seek state, with an invalid mSeekTarget and a valid mCurrentSeekTarget. I need to catch a bus, but will continue looking at this there.
Flags: needinfo?(bobbyholley)
I think the issue is that our seek logic doesn't have the ability to cancel the current seek and start a new one. When the MDSM is in DECODER_STATE_SEEKING, the state machine is basically stuck, assuming that the seek promise is going to get called back.

However, if we quickly seek twice, it's quite plausible that the youtube player doesn't even bother to initiate a load for the first chunk. So the player dutifully buffers the data near the logical seek point, while MediaSourceReader is stuck waiting on the old seek point, whose data isn't coming.

It seems like we basically want a CancelSeek on MediaSourceReader that rejects the promise and resets all the seek state. Matt, does that sound right to you?

We could even write a test for this. :-)
Flags: needinfo?(matt.woodrow)
MediaSourceReader already handles a second seek request by rejecting the initial seek promise and returning a new one.

We could just update MediaDecoderStateMachine to make use of this and not need CancelSeek at all.

That said, I'm not opposed to having an explicit CancelSeek instead if you prefer.
Flags: needinfo?(matt.woodrow)
(In reply to Matt Woodrow (:mattwoodrow) from comment #4)
> MediaSourceReader already handles a second seek request by rejecting the
> initial seek promise and returning a new one.
> 
> We could just update MediaDecoderStateMachine to make use of this and not
> need CancelSeek at all.
> 
> That said, I'm not opposed to having an explicit CancelSeek instead if you
> prefer.

Oh, I see. The advantage of an explicit CancelSeek is that we wouldn't have to disambiguate the promise rejections, and could wait for the rejection before starting the new seek. We could probably make it work either way though. I'll hack something up tomorrow.
Assignee: nobody → bobbyholley
Attachment #8549967 - Flags: superreview?(cpearce)
Attachment #8549967 - Flags: review?(matt.woodrow)
Tracking it is a pain, and it's only used by OggReader.
Attachment #8549968 - Flags: review?(matt.woodrow)
mWaitingForSeekData is modified in NotifyTimeRangesChanged, which is
invoked on the main thread. One would hope that all of these other members
are only touched on the decode task queue.
Attachment #8549969 - Flags: review?(matt.woodrow)
The comments indicate that they're supposed to be used for setting mDiscontinuity
on the samples, but that never actually happens (and appears to happen in
MP4Reader.cpp). Resetting them in Request{Audio,Video}Data doesn't make any sense
at all. So we repurpose them to track our seek stage.
Attachment #8549971 - Flags: review?(matt.woodrow)
This is necessary so that we can call CancelSeek at the same moment we determine
that it needs to be called without round-tripping between threads.
Attachment #8549972 - Flags: review?(matt.woodrow)
Attachment #8549972 - Flags: review?(cpearce)
This is the part I'm least sure about. Hopefully cpearce can point out any
pitfalls.
Attachment #8549974 - Flags: review?(matt.woodrow)
Attachment #8549974 - Flags: review?(cpearce)
Attachment #8549976 - Flags: review?(matt.woodrow)
Attachment #8549976 - Flags: review?(cpearce)
Comment on attachment 8549967 [details] [diff] [review]
Part 1 - Remove unnecessary arguments to ::Seek. v1

Review of attachment 8549967 [details] [diff] [review]:
-----------------------------------------------------------------

Skimmed through this a bit, looks like the only meaningful change is to use mStartTime instead of aStartTime, which should be safe.
Attachment #8549967 - Flags: review?(matt.woodrow) → review+
Attachment #8549968 - Flags: review?(matt.woodrow) → review+
Attachment #8549967 - Flags: superreview?(cpearce) → superreview+
Attachment #8549969 - Flags: review?(matt.woodrow) → review+
Attachment #8549972 - Flags: review?(cpearce) → review+
Attachment #8549971 - Flags: review?(matt.woodrow) → review+
Attachment #8549972 - Flags: review?(matt.woodrow) → review+
Attachment #8549974 - Flags: review?(cpearce) → review+
Comment on attachment 8549976 [details] [diff] [review]
Part 7 - Tests. v1

Review of attachment 8549976 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/media/mediasource/test/test_SeekTwice_mp4.html
@@ +44,5 @@
> +      return p;
> +    }).then(function() {
> +      ok(true, "Got seeking event");
> +      var p = once(el, 'seeked');
> +      el.currentTime = 6; // Seek past the gap.

return p;
Attachment #8549976 - Flags: review?(matt.woodrow) → review+
Attachment #8549976 - Flags: review?(cpearce) → review+
Comment on attachment 8549974 [details] [diff] [review]
Part 6 - Make seeks cancelable. v1

Review of attachment 8549974 [details] [diff] [review]:
-----------------------------------------------------------------

r=mattwoodrow with the change to SeekCompleted mentioned in irc.
Attachment #8549974 - Flags: review?(matt.woodrow) → review+
(In reply to Bobby Holley (Busy with media, don't ask for DOM/JS/XPConnect things) from comment #17)
> Thanks for the fast reviews guys!
> 
> https://treeherder.mozilla.org/#/jobs?repo=try&revision=e9c89a1ecfbe

There were 2 failures on the above push:
(1) I forgot to disable the test on linux, where we don't support H264.
(2) We were hitting an assertion I added in one of the patches. I'm attaching a followup patch just to detect that case and bail out. We'd really like to get this patch into the next beta and today is saturday in New Zealand. Given that this patch is quite safe, I'm flagging Chris for retroactive review. I'll also file a followup bug to fix up the MDSM to not violate the invariants.
(In reply to Bobby Holley (Busy with media, don't ask for DOM/JS/XPConnect things) from comment #18)
> We were hitting an assertion I added in one of the patches. I'm
> attaching a followup patch just to detect that case and bail out.

(Note that I managed to reproduce the failure locally, and verify my fix).
Depends on: 1119757, 1120266
The MDSM really shouldn't be issuing these. The correct solution (which I'll
file a followup bug for) is to fix the MDSM to not do that. But rejecting the
promise with CANCELED is a lot safer, so we do that for now.
Attachment #8550435 - Flags: review?(cpearce)
Attachment #8550435 - Flags: review?(cpearce) → review+
Test disabled across the board because at this point it fails for sure on Windows (as your last Try push showed???) and Android (which your Try pushes didn't actually test - yay chunking). Rather than keep the tree closed while I wait to find out what other platforms it's broken on, I've disabled it across the board. You sort it out.
https://hg.mozilla.org/integration/mozilla-inbound/rev/cde7eff18b1a
Fails intermittently on OSX too.
Depends on: 1122765
Bobby, I didn't nominate this for 36b2 over the weekend because I was concerned about the test failures Ryan reported in comment #22. Do you think they're ok for 36beta3 as-is, or if I should wait for the the follow-up bug?
Flags: needinfo?(bobbyholley)
(In reply to Ralph Giles (:rillian) from comment #25)
> Bobby, I didn't nominate this for 36b2 over the weekend because I was
> concerned about the test failures Ryan reported in comment #22. Do you think
> they're ok for 36beta3 as-is, or if I should wait for the the follow-up bug?

We should definitely uplift this - hopefully it's not too late?

The tests did fail, but they were the first/only MSE mp4 tests that anybody ever attempted to put in the tree. This is kind of terrible because that's the exact configuration we're shipping in 4 weeks, but I wouldn't attribute the test failures to this bug. We definitely want this fix in the beta.
Flags: needinfo?(bobbyholley)
Comment on attachment 8549967 [details] [diff] [review]
Part 1 - Remove unnecessary arguments to ::Seek. v1

Ok, thanks for clarifying, and now this has had the weekend to settle. Requesting uplift approval for all patches on this bug for Aurora and Beta, 36 beta 2 if possible. This was another of our major MSE blockers for 36.

Approval Request Comment
[Feature/regressing bug #]: MSE
[User impact if declined]: YouTube playback sometimes doesn't work after seeking.
[Describe test coverage new/current, TBPL]: Landed on m-c. In Nightly over the weekend.

[Risks and why]: Risk is moderate. There are a lot of changes here, and in general video playback code. We think it works, or is at least better than what we have in-tree now. We'd like to get this in all branches to maximize early testing of the non-MSE changes.

[String/UUID change made/needed]: None.
Attachment #8549967 - Flags: approval-mozilla-beta?
Attachment #8549967 - Flags: approval-mozilla-aurora?
Attachment #8549967 - Flags: approval-mozilla-beta?
Attachment #8549967 - Flags: approval-mozilla-beta+
Attachment #8549967 - Flags: approval-mozilla-aurora?
Attachment #8549967 - Flags: approval-mozilla-aurora+
Flags: qe-verify-
Blocks: 1126052
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: