MSE-in-Workers: Narrow the SourceBuffer GC exclusion
Before this change, the MSE SourceBuffer's coded frame eviction algorithm (run during the synchronous portion of appendBuffer() as part of the Prepare Append Algorithm) returned early without evicting anything if the media element had not yet reached HAVE_METADATA. In MSE, the only way for the media element to have reached HAVE_METADATA (at least in Chromium) is for all of the SourceBuffers currently in the MediaSource to have all had enough data appended to each of them such that at least one initialization segment each has been successfully processed. This has two problems: 1) It relies upon external state unnecessarily: the SourceBuffer knows if it has potentially buffered media frames already beyond the first init segment if its |first_initialization_segment_received_| flag is true. A (good) side effect of switching to using this flag instead of consulting the media element is a simplification of the dependency upon media element state in the current MSE-in-Workers feature work that is clarifying such dependencies into the MediaSourceAttachment interface. 2) Making eviction a noop when there is at least one other SourceBuffer that has not yet received an initialization segment lets an app append potentially too much without having to handle the pushback of a quota-exceeded-error earlier, limiting the effectiveness of MSE's automatic garbage collection of coded frames, especially when device memory is constrained. This change switches from using MediaElement.readyState < HAVE_METADATA to instead using !first_initialization_segment_received_ as the condition which would allow skipping coded frame eviction during an appendBuffer(). Note: This condition was always intended as a runtime performance optimization, and is part of the implementation area that is allowed flexibility by the MSE specification. BUG=878133 Change-Id: I1173fbdf8aec5e4521b0f73049aeeb7c56ab7ab7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2393356Reviewed-by:Will Cassella <cassew@google.com> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org> Cr-Commit-Position: refs/heads/master@{#804509}
Showing
Please register or sign in to comment