Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(386)

Issue 1008463002: Fix MSE GC, make it less aggressive, more spec-compliant (Closed)

Created:
5 years, 9 months ago by servolk
Modified:
5 years, 4 months ago
CC:
chromium-reviews, feature-media-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Fix MSE GC, make it less aggressive, more spec-compliant There are a few a problems with current MSE Garbage Collection (GC from now on): 1. It doesn't take into account current media_time as MSE spec requires (https://codereview.chromium.org/341083004/ was supposed to fix that, but it was never merged). The MSE spec clearly mentions what should be the state of the media element based on the buffered ranges (see MSE spec 2.4.4 SourceBuffer Monitoring). Since there is a latency between the read position in the source buffer stream and the playback position, the MSE garbage collection must be adjusted so as to not remove the playback position from the buffered ranges. 2. It is too aggressive, i.e. sometimes it throws away chunks of data from SourceBufferStream that have not been read from DemuxerStream yet, have not been consumed by the media pipeline and many apps don't expect that appended data will be thrown away prematurely, so they don't attempt to fill in the gaps created by throwing away data (see crbug.com/421694). This CL fixes those issues by: 1. Making GC algorithm (SourceBufferStream::GarbageCollectIfNeeded) callable from blink level via WebSourceBuffer::evictCodedFrames/ ChunkDemuxer::EvictCodedFrames. This will allow blink to initiate GC from outside of append loop as discussed in CL 341083004 and will allow blink to know that GC has failed to evict enough data and throw QuotaExceededErr in that case as prescribed by MSE spec (see step #6 in section 3.5.4 of https://w3c.github.io/media-source/). Related CL for blink: https://codereview.chromium.org/1013923002/ 2. Passing HTMLMediaElement::currentTime from blink level into ChunkDemuxer::EvictCodedFrames and into MSE GC algorithm. The GC algorithm is adjusted to stop throwing away data when the current playback position is reached. 3. Making the GC algorithm stop when freeing data from the back of MSE SourceBuffer and when reaching the last append position. BUG=421694, 440173, 474806 Committed: https://crrev.com/e1f21238dfd533a3e8e5e738c134822a65a40ecf Cr-Commit-Position: refs/heads/master@{#344908}

Patch Set 1 #

Patch Set 2 : Pass get_media_time_cb into ChunkDemuxer constructor #

Patch Set 3 : Added comment for ChunkDemuxer::EvictFrames #

Patch Set 4 : Updated comments #

Patch Set 5 : Rebase to ToT #

Patch Set 6 : Renderer should return kNoTimestamp when theres no time source yet. #

Total comments: 23

Patch Set 7 : CR feedback #

Patch Set 8 : Added new test case: GarbageCollection_SaveDataAtPlaybackPosition #

Total comments: 8

Patch Set 9 : Added test case for GC with playback position beyond buffered + nits #

Patch Set 10 : Rebase to ToT #

Patch Set 11 : Use WebMediaPlayer::currentTime instead of Pipeline::GetMediaTime #

Patch Set 12 : Allow getting currentTimeInternal in HAVE_NOTHING state #

Patch Set 13 : Protect Demuxer::EvictFrames with lock #

Patch Set 14 : Use currentTime for GC in WebMediaPlayerAndroid #

Patch Set 15 : Android buildfix #

Patch Set 16 : Missing paren #

Patch Set 17 : Use media_time, if available, in FreeBuffersAfterLastAppended + extra logs #

Patch Set 18 : Pass currentTime from blink level, instead of using GetMediaTimeCB #

Patch Set 19 : Use media_time instead of next read position in GC algorithm #

Patch Set 20 : cleanup #

Patch Set 21 : Pass new data size into evictCodedFrames #

Patch Set 22 : Rebase to ToT #

Patch Set 23 : Protect most recent append range during front GC, fixes crbug.com/440173 #

Patch Set 24 : A bit more informative logging + fixed unit test #

Total comments: 14

Patch Set 25 : Pass newDataSize down to SourceState #

Patch Set 26 : Use newDataSize in SourceBufferStream::GarbageCollectIfNeeded #

Total comments: 14

Patch Set 27 : Addressed CR feedback #

Patch Set 28 : Rebase on top of dummy WebSourceBufferImpl::evictCodedFrames CL #

Total comments: 10

Patch Set 29 : Improved unit test #

Patch Set 30 : Updated unit test, comments and explanations #

Patch Set 31 : Added overflow check to sanity checks and use CHECK instead of DCHECK #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+585 lines, -133 lines) Patch
M media/blink/websourcebuffer_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 1 chunk +4 lines, -4 lines 0 comments Download
M media/filters/chunk_demuxer.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 3 chunks +17 lines, -0 lines 0 comments Download
M media/filters/chunk_demuxer.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 6 chunks +117 lines, -0 lines 1 comment Download
M media/filters/chunk_demuxer_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 5 chunks +113 lines, -14 lines 0 comments Download
M media/filters/source_buffer_range.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +2 lines, -0 lines 0 comments Download
M media/filters/source_buffer_range.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +10 lines, -0 lines 0 comments Download
M media/filters/source_buffer_stream.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 3 chunks +16 lines, -7 lines 0 comments Download
M media/filters/source_buffer_stream.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 9 chunks +95 lines, -33 lines 0 comments Download
M media/filters/source_buffer_stream_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 24 chunks +211 lines, -75 lines 0 comments Download

Messages

Total messages: 68 (11 generated)
servolk
On 2015/03/12 18:25:13, servolk wrote: > mailto:servolk@chromium.org changed reviewers: > + mailto:gunsch@chromium.org, mailto:lcwu@chromium.org, mailto:philipj@opera.com, > ...
5 years, 9 months ago (2015-03-12 18:27:11 UTC) #2
philipj_slow
Is there a Blink CL that adds WebSourceBuffer::evictFrames() and calls it to show how this ...
5 years, 9 months ago (2015-03-13 03:35:52 UTC) #3
servolk
On 2015/03/13 03:35:52, philipj_UTC7 wrote: > Is there a Blink CL that adds WebSourceBuffer::evictFrames() and ...
5 years, 9 months ago (2015-03-13 17:53:20 UTC) #4
philipj_slow
On 2015/03/13 17:53:20, servolk wrote: > On 2015/03/13 03:35:52, philipj_UTC7 wrote: > > Is there ...
5 years, 9 months ago (2015-03-13 18:03:46 UTC) #5
servolk
On 2015/03/13 18:03:46, philipj_UTC7 wrote: > On 2015/03/13 17:53:20, servolk wrote: > > On 2015/03/13 ...
5 years, 9 months ago (2015-03-13 20:35:16 UTC) #6
philipj_slow
On 2015/03/13 20:35:16, servolk wrote: > On 2015/03/13 18:03:46, philipj_UTC7 wrote: > > On 2015/03/13 ...
5 years, 9 months ago (2015-03-15 03:45:40 UTC) #7
servolk
On 2015/03/15 03:45:40, philipj wrote: > On 2015/03/13 20:35:16, servolk wrote: > > On 2015/03/13 ...
5 years, 6 months ago (2015-05-29 23:23:50 UTC) #9
servolk
On 2015/05/29 23:23:50, servolk wrote: > On 2015/03/15 03:45:40, philipj wrote: > > On 2015/03/13 ...
5 years, 6 months ago (2015-06-02 19:21:05 UTC) #10
wolenetz
On 2015/06/02 19:21:05, servolk wrote: > On 2015/05/29 23:23:50, servolk wrote: > > On 2015/03/15 ...
5 years, 6 months ago (2015-06-03 18:01:54 UTC) #11
wolenetz
Looking pretty good. Some nits and questions: https://codereview.chromium.org/1008463002/diff/100001/media/filters/chunk_demuxer.cc File media/filters/chunk_demuxer.cc (right): https://codereview.chromium.org/1008463002/diff/100001/media/filters/chunk_demuxer.cc#newcode138 media/filters/chunk_demuxer.cc:138: // |media_time| ...
5 years, 6 months ago (2015-06-04 00:38:57 UTC) #12
wolenetz
Looking pretty good. Some nits and questions:
5 years, 6 months ago (2015-06-04 00:39:00 UTC) #13
wolenetz
On 2015/06/04 00:39:00, wolenetz wrote: > Looking pretty good. Some nits and questions: I'm not ...
5 years, 6 months ago (2015-06-04 00:42:10 UTC) #14
servolk
Sorry, the change to media/blink/webmediaplayer_impl.cc in the last patchset is due to rebase, not related ...
5 years, 6 months ago (2015-06-04 03:03:02 UTC) #15
wolenetz
https://codereview.chromium.org/1008463002/diff/100001/media/filters/chunk_demuxer.cc File media/filters/chunk_demuxer.cc (right): https://codereview.chromium.org/1008463002/diff/100001/media/filters/chunk_demuxer.cc#newcode1356 media/filters/chunk_demuxer.cc:1356: DecodeTimestamp::FromPresentationTime(get_media_time_cb_.Run()); On 2015/06/04 03:03:01, servolk wrote: > On 2015/06/04 ...
5 years, 6 months ago (2015-06-04 20:06:50 UTC) #16
servolk
https://codereview.chromium.org/1008463002/diff/100001/media/filters/chunk_demuxer.cc File media/filters/chunk_demuxer.cc (right): https://codereview.chromium.org/1008463002/diff/100001/media/filters/chunk_demuxer.cc#newcode1356 media/filters/chunk_demuxer.cc:1356: DecodeTimestamp::FromPresentationTime(get_media_time_cb_.Run()); On 2015/06/04 20:06:50, wolenetz wrote: > On 2015/06/04 ...
5 years, 6 months ago (2015-06-04 20:22:47 UTC) #17
wolenetz
LGTM
5 years, 6 months ago (2015-06-04 20:42:06 UTC) #18
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1008463002/160001
5 years, 6 months ago (2015-06-04 20:44:33 UTC) #20
commit-bot: I haz the power
Try jobs failed on following builders: android_chromium_gn_compile_dbg on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/android_chromium_gn_compile_dbg/builds/78132)
5 years, 6 months ago (2015-06-04 21:04:43 UTC) #22
wolenetz
It looks like the android bots are complaining because the Android media-source-player fork of the ...
5 years, 6 months ago (2015-06-04 21:31:04 UTC) #23
servolk
On 2015/06/04 21:31:04, wolenetz wrote: > It looks like the android bots are complaining because ...
5 years, 6 months ago (2015-06-04 21:42:03 UTC) #24
wolenetz
On 2015/06/04 21:42:03, servolk wrote: > On 2015/06/04 21:31:04, wolenetz wrote: > > It looks ...
5 years, 6 months ago (2015-06-04 21:57:30 UTC) #25
servolk
On 2015/06/04 21:57:30, wolenetz wrote: > On 2015/06/04 21:42:03, servolk wrote: > > On 2015/06/04 ...
5 years, 6 months ago (2015-06-04 22:12:40 UTC) #26
servolk
On 2015/06/04 22:12:40, servolk wrote: > On 2015/06/04 21:57:30, wolenetz wrote: > > On 2015/06/04 ...
5 years, 6 months ago (2015-06-05 22:02:20 UTC) #27
wolenetz
On 2015/06/05 22:02:20, servolk wrote: > On 2015/06/04 22:12:40, servolk wrote: > > On 2015/06/04 ...
5 years, 6 months ago (2015-06-05 22:41:24 UTC) #28
servolk
On 2015/06/05 22:41:24, wolenetz wrote: > On 2015/06/05 22:02:20, servolk wrote: > > On 2015/06/04 ...
5 years, 6 months ago (2015-06-15 18:24:57 UTC) #30
servolk
Please take another look. I've reworked this CL a bit to pass the current playback ...
5 years, 5 months ago (2015-06-26 18:14:01 UTC) #31
servolk
On 2015/06/26 18:14:01, servolk wrote: > Please take another look. > I've reworked this CL ...
5 years, 5 months ago (2015-07-07 23:03:02 UTC) #32
servolk
On 2015/07/07 23:03:02, servolk wrote: > On 2015/06/26 18:14:01, servolk wrote: > > Please take ...
5 years, 5 months ago (2015-07-13 20:51:43 UTC) #33
wolenetz
On 2015/07/13 20:51:43, servolk wrote: > On 2015/07/07 23:03:02, servolk wrote: > > On 2015/06/26 ...
5 years, 5 months ago (2015-07-13 22:26:17 UTC) #34
servolk
On 2015/07/13 22:26:17, wolenetz wrote: > On 2015/07/13 20:51:43, servolk wrote: > > On 2015/07/07 ...
5 years, 5 months ago (2015-07-14 21:07:12 UTC) #35
servolk
On 2015/07/14 21:07:12, servolk wrote: > On 2015/07/13 22:26:17, wolenetz wrote: > > On 2015/07/13 ...
5 years, 4 months ago (2015-07-28 01:44:29 UTC) #36
servolk
On 2015/07/28 01:44:29, servolk wrote: > On 2015/07/14 21:07:12, servolk wrote: > > On 2015/07/13 ...
5 years, 4 months ago (2015-07-30 23:06:02 UTC) #37
servolk
On 2015/07/30 23:06:02, servolk wrote: > On 2015/07/28 01:44:29, servolk wrote: > > On 2015/07/14 ...
5 years, 4 months ago (2015-08-04 20:22:43 UTC) #38
wolenetz
My sincere apologies for slow review on this. I'll get to this soon.
5 years, 4 months ago (2015-08-04 21:33:23 UTC) #39
servolk
On 2015/08/04 21:33:23, wolenetz wrote: > My sincere apologies for slow review on this. I'll ...
5 years, 4 months ago (2015-08-11 17:23:37 UTC) #40
wolenetz
On 2015/08/11 17:23:37, servolk wrote: > On 2015/08/04 21:33:23, wolenetz wrote: > > My sincere ...
5 years, 4 months ago (2015-08-11 17:27:20 UTC) #41
wolenetz
On 2015/08/11 17:27:20, wolenetz wrote: > On 2015/08/11 17:23:37, servolk wrote: > > On 2015/08/04 ...
5 years, 4 months ago (2015-08-12 20:13:43 UTC) #42
wolenetz
At long last: next round of review. In general, this looks good, though I would ...
5 years, 4 months ago (2015-08-12 21:09:57 UTC) #43
wolenetz
Updated comment: https://codereview.chromium.org/1008463002/diff/460001/media/blink/websourcebuffer_impl.cc File media/blink/websourcebuffer_impl.cc (right): https://codereview.chromium.org/1008463002/diff/460001/media/blink/websourcebuffer_impl.cc#newcode85 media/blink/websourcebuffer_impl.cc:85: size_t newDataSize) { On 2015/08/12 21:09:57, wolenetz ...
5 years, 4 months ago (2015-08-12 21:13:26 UTC) #44
servolk
https://codereview.chromium.org/1008463002/diff/460001/media/blink/websourcebuffer_impl.cc File media/blink/websourcebuffer_impl.cc (right): https://codereview.chromium.org/1008463002/diff/460001/media/blink/websourcebuffer_impl.cc#newcode85 media/blink/websourcebuffer_impl.cc:85: size_t newDataSize) { On 2015/08/12 21:13:26, wolenetz wrote: > ...
5 years, 4 months ago (2015-08-13 00:31:42 UTC) #45
servolk
https://codereview.chromium.org/1008463002/diff/460001/media/blink/websourcebuffer_impl.cc File media/blink/websourcebuffer_impl.cc (right): https://codereview.chromium.org/1008463002/diff/460001/media/blink/websourcebuffer_impl.cc#newcode85 media/blink/websourcebuffer_impl.cc:85: size_t newDataSize) { On 2015/08/13 00:31:42, servolk wrote: > ...
5 years, 4 months ago (2015-08-20 02:45:27 UTC) #46
wolenetz
Mostly minor stuff remaining. Thanks for adding the heuristic, though there is definitely room for ...
5 years, 4 months ago (2015-08-20 23:23:37 UTC) #47
servolk
https://codereview.chromium.org/1008463002/diff/460001/media/blink/websourcebuffer_impl.cc File media/blink/websourcebuffer_impl.cc (right): https://codereview.chromium.org/1008463002/diff/460001/media/blink/websourcebuffer_impl.cc#newcode85 media/blink/websourcebuffer_impl.cc:85: size_t newDataSize) { On 2015/08/20 23:23:37, wolenetz wrote: > ...
5 years, 4 months ago (2015-08-21 01:32:09 UTC) #48
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1008463002/540001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1008463002/540001
5 years, 4 months ago (2015-08-21 16:00:36 UTC) #50
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: win_chromium_x64_rel_ng on tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_x64_rel_ng/builds/93976)
5 years, 4 months ago (2015-08-21 16:47:29 UTC) #52
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1008463002/540001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1008463002/540001
5 years, 4 months ago (2015-08-21 17:45:26 UTC) #54
wolenetz
Almost there! :) Marking not lgtm due to the current estimation logic is flawed (integer ...
5 years, 4 months ago (2015-08-21 18:15:57 UTC) #55
servolk
https://codereview.chromium.org/1008463002/diff/540001/media/filters/chunk_demuxer.cc File media/filters/chunk_demuxer.cc (right): https://codereview.chromium.org/1008463002/diff/540001/media/filters/chunk_demuxer.cc#newcode405 media/filters/chunk_demuxer.cc:405: DCHECK(bufferedVideoSize + bufferedAudioSize > 0); On 2015/08/21 18:15:57, wolenetz ...
5 years, 4 months ago (2015-08-21 18:19:14 UTC) #56
commit-bot: I haz the power
Dry run: A disapproval has been posted by following reviewers: wolenetz@chromium.org. Please make sure to ...
5 years, 4 months ago (2015-08-21 18:32:24 UTC) #58
servolk
https://codereview.chromium.org/1008463002/diff/540001/media/filters/chunk_demuxer.cc File media/filters/chunk_demuxer.cc (right): https://codereview.chromium.org/1008463002/diff/540001/media/filters/chunk_demuxer.cc#newcode405 media/filters/chunk_demuxer.cc:405: DCHECK(bufferedVideoSize + bufferedAudioSize > 0); On 2015/08/21 18:19:14, servolk ...
5 years, 4 months ago (2015-08-21 19:06:45 UTC) #59
wolenetz
lgtm % additional sanity nit. Not using floating point for the ratio seems ok to ...
5 years, 4 months ago (2015-08-21 19:39:37 UTC) #60
servolk
https://codereview.chromium.org/1008463002/diff/540001/media/filters/chunk_demuxer.cc File media/filters/chunk_demuxer.cc (right): https://codereview.chromium.org/1008463002/diff/540001/media/filters/chunk_demuxer.cc#newcode405 media/filters/chunk_demuxer.cc:405: DCHECK(bufferedVideoSize + bufferedAudioSize > 0); On 2015/08/21 19:39:37, wolenetz ...
5 years, 4 months ago (2015-08-21 20:16:54 UTC) #61
wolenetz
On 2015/08/21 20:16:54, servolk wrote: > https://codereview.chromium.org/1008463002/diff/540001/media/filters/chunk_demuxer.cc > File media/filters/chunk_demuxer.cc (right): > > https://codereview.chromium.org/1008463002/diff/540001/media/filters/chunk_demuxer.cc#newcode405 > ...
5 years, 4 months ago (2015-08-21 20:17:58 UTC) #64
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1008463002/600001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1008463002/600001
5 years, 4 months ago (2015-08-21 20:18:52 UTC) #65
wolenetz
From offline chat: https://codereview.chromium.org/1008463002/diff/600001/media/filters/chunk_demuxer.cc File media/filters/chunk_demuxer.cc (right): https://codereview.chromium.org/1008463002/diff/600001/media/filters/chunk_demuxer.cc#newcode407 media/filters/chunk_demuxer.cc:407: CHECK(bufferedAudioSize < tl;dr off by one, ...
5 years, 4 months ago (2015-08-21 20:25:02 UTC) #66
commit-bot: I haz the power
Committed patchset #31 (id:600001)
5 years, 4 months ago (2015-08-21 23:39:17 UTC) #67
commit-bot: I haz the power
5 years, 4 months ago (2015-08-21 23:40:09 UTC) #68
Message was sent while issue was closed.
Patchset 31 (id:??) landed as
https://crrev.com/e1f21238dfd533a3e8e5e738c134822a65a40ecf
Cr-Commit-Position: refs/heads/master@{#344908}

Powered by Google App Engine
This is Rietveld 408576698