Skip to content

Fixes for discharging preloaded content

Vinay Rosenberg requested to merge github/fork/bbc/prebufferSinkFixes into development

Created by: robertbryer

This PR fixes two issues with using the preload() function and discharging before it's filled up until buffer target:

  1. If a video element is attached while it's still pre-loading content, the fragments appended from the discharge() function in BufferController send bytes_appended events out. This causes the scheduling loop to be triggered a second time, meaning remaining fragments will be downloaded 2 at time until buffer target is reached. To fix it, the fragments discharged from the PreBufferSink are tracked in array dischargeFragments and bytes_appended events are not sent out for those fragments.
  2. If an init segment is discharged it is appended to the SourceBuffer twice. The discharge function checks the InitCache when chunk is an init segment. It returns the exact same init segment as initChunk, and so it gets appended twice to the source buffer.

You can reproduce both of these by calling preload and attaching a video element quickly after, before you reach the buffer target.

Merge request reports