Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MULTI_THREAD timing issue on Samsung TV #1556

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

peaBerberian
Copy link
Collaborator

We recently noticed an issue when loading multiple contents that led to infinite loading, that was only seen on Samsung TVs.

After investigation, we noticed that there's a small window of time where the messages sent by the WebWorker are not listened by the main thread, that lead to those infinite loading as the main thread is still waiting for a message the Worker already sent.

This happened if the message was sent by the worker during the short time interval between:

  • "Content preparation": When main thread asks the worker to load the MPD and to initialize some things
  • and "Content start": We actually start to play that content

Basically, this time interval should roughly be equal to the time it takes to "stop" the previous content (which we do by emptying the HTMLMediaElement's src attribute), so a really short time yet still too long to possibly lead to issue (if for example the MPD loads faster than the stop operation, the main thread wouldn't get the info).

There's multiple ways we could fix the issue. For now, I chose to add a way I'm not perfectly happy with due to the amount of logic added but which should work:

  • At "content preparation", we listen to worker messages. For those that we can process immediately (for now, just logs) we process them right now, for others, we push them to a special message queue until the content is started

  • At "content start", we check the message queue and if not empty, we process all messages from it at that point.

I tested it with success on a Samsung TV reproducing the issue.

We recently noticed an issue when loading multiple contents that led to
infinite loading, that was only seen on Samsung TVs.

After investigation, we noticed that there's a small window of time
where the messages sent by the WebWorker are not listened by the main
thread, that lead to those infinite loading as the main thread is still
waiting for a message the Worker already sent.

This happened if the message was sent by the worker during the short time
interval between:
  - "Content preparation": When main thread asks the worker to load the MPD
    and to initialize some things
  - and "Content start": We actually start to play that content

Basically, this time interval should roughly be equal to the time it
takes to "stop" the previous content (which we do by emptying the
`HTMLMediaElement`'s src attribute), so a really short time yet still too
long to possibly lead to issue (if for example the MPD loads faster than
the stop operation, the main thread wouldn't get the info).

There's multiple ways we could fix the issue. For now, I chose to add a
way I'm not perfectly happy with due to the amount of logic added but
which should work:

  - At "content preparation", we listen to worker messages. For those
    that we can process immediately (for now, just logs) we process them
    right now, for others, we push them to a special message queue until
    the content is started

  - At "content start", we check the message queue and if not empty, we
    process all messages from it at that point.

I tested it with success on a Samsung TV reproducing the issue.
@peaBerberian peaBerberian added bug This is an RxPlayer issue (unexpected result when comparing to the API) Priority: 0 (Very high) This issue or PR has a very high priority. Efforts should be concentrated on it first. MultiThread Concerns specifically the multithreaded mode of the RxPlayer labels Sep 25, 2024
@peaBerberian peaBerberian added this to the 4.2.0 milestone Sep 25, 2024
@peaBerberian peaBerberian merged commit c80e239 into dev Sep 25, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is an RxPlayer issue (unexpected result when comparing to the API) MultiThread Concerns specifically the multithreaded mode of the RxPlayer Priority: 0 (Very high) This issue or PR has a very high priority. Efforts should be concentrated on it first.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants