video-dev / video-dev/hls.js

Samsung Tizen - Performance degradation when initiating long streams

Open
#7,106 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Documentation Revisit-at-later-release-cycle
Dominant language
TypeScript
Stars
16.9k
Forks
2.8k
Avg merge
1d 12h
Merged PRs (30d)
27

Description

What version of Hls.js are you using?

1.5.20

What browser (including version) are you using?

Chromium v56/63 (Tizen fork)

What OS (including version) are you using?

Tizen

Test stream

No response

Configuration
{
  backBufferLength: 30,
  enableWorker: true,
  highBufferWatchdogPeriod: 5,
  liveSyncDurationCount: 5,
  maxBufferLength: 30,
  maxMaxBufferLength: 60,
  nudgeMaxRetry: 10,
  workerPath: 'path/to/hls.worker.js'
}
Additional player setup steps

NOTE: I originally posted this issue on the video-dev/hlsjs Slack channel. I am copying a summary here for posterity, in the event others come across this problem.

Original Slack message (edited for clarity)

We maintain an application that runs on various devices, including Samsung Tizen TV's and other Smart TV's/STB's. After recently updating the HLS.js player from 1.1.5 to 1.5.x, I'm noticing a very long stream startup delay on 2018/19 devices (which use Chrome v56/63 respectively) as a result of the application being entirely locked up during this time, indicating an apparent cpu bottleneck.

The issue seems to be exacerbated when playing longer streams (~3-4 hours).

I've been able to narrow this issue down to the player getting bottlenecked when:

  • Parsing a variant playlist and subtitle (VTT) manifest concurrently, or
  • Parsing a variant playlist, then immediately ramping to a different variant and parsing a new playlist

It seems that the m3u8-parser is blocking the main thread whenever the player needs to parse multiple variants in sequence/concurrently.

Thread summary
  • The issue occurs on all versions from 1.4.0 and higher.
  • I've been able to pinpoint the bottleneck to the Fragment object creation in the level parsing block. The loop continues to execute, but becomes progressively slower during each iteration. This behavior, combined with all of the conditions seems to indicate a possible V8 optimization problem on these older devices.
Findings/solution

This issue occurs due to a combination of how Vite is bundling our client application, and older versions of the V8 engine having sub-optimal memory management and function de-optimizations when using the ESM version of this library. The solution in this case was to alias the UMD/ES5 version of the library in our Vite config:

resolve: {
  alias: {
    'hls.js': 'node_modules/hls.js/dist/hls.js'
  }
}
Checklist
Steps to reproduce
  1. Start playing a stream with a length of over ~3 hours. Streams that have sidecar subtitle files (i.e. VTT) are more likely to exhibit this issue.
Expected behaviour

Stream starts and plays within ~10 seconds

What actually happened?

Observe startup delay along with an unresponsive UI, indicating a possible thread starvation. Custom log output shows that the fragment creation latency gets progressively worse over time (note the subtitle loop takes ~48 seconds to complete)

Image
Console output
n/a
Chrome media internals output
n/a

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the m3u8-parser level parsing path, especially Fragment object creation, and the Vite resolve configuration described in the issue. Reproduce with a stream longer than three hours and sidecar VTT subtitles on the affected Tizen devices; done means confirming whether startup delay and UI blocking remain and documenting the applicable configuration or project change.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript, vite
Domain
frontend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.