Skip to content

Conversation

@peaBerberian
Copy link
Collaborator

@peaBerberian peaBerberian commented Sep 2, 2025

An issue, #1736, noticed that we have a problem with the getPeriodForTime util which links the current playback timestamp and the Period to which it is associated to.

The way the util was written means it had to be looped over from the last to the first, but I don't know why I decided to replace it with a fancier for...of (which goes from first to last) in a totally unrelated refacto (#1507).

This broke the logic and lead, with conditions that are hard to predict, to some infinite rebuffering issues.

I also made some other code more resilient here, because I thought that I saw another issue first. I don't really know if that other case is possible but I thought that it didn't cost anything to be resilient there.

An issue, #1736, noticed
that we have an issue with the `getPeriodForTime` util which links time
and Period.

The way the util was written means it had to be looped over from the
last to the first, but I don't know why I decided to replace it with a
fancier `for...of` (which goes from first to last) in a totally
unrelated refacto (#1507).

This broke the logic and lead in conditions that are hard to predict
infinite rebuffering issues.

I also made some other code more resilient here, because I thought that
I saw another issue first. I don't really know if that other case is
possible but I thought that it didn't cost anything to be resilient
there.
@peaBerberian peaBerberian added the bug This is an RxPlayer issue (unexpected result when comparing to the API) label Sep 3, 2025
@peaBerberian peaBerberian added this to the 4.4.0 milestone Sep 3, 2025
@peaBerberian peaBerberian added the Priority: 0 (Very high) This issue or PR has a very high priority. Efforts should be concentrated on it first. label Sep 3, 2025
// Last check just for resilience reasons that the wanted Period is
// not one of the already-handled ones
return;
}
Copy link
Collaborator Author

@peaBerberian peaBerberian Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: This was the part just for resilience, as I was under the impression that the edge case of:

  • time is exactly at a Period's end
  • next Period is later (there's a discontinuity currently)

Was not properly considered here, but I never reproduced an issue with it.


Only risk that I can think of from that update is that we now compute nextPeriod before the periodStreamCleared() callback and currentCanceller.cancel() both which may perform unknown side-effects.

We could also just re-compute nextPeriod there - at the expense of code readability - as you wish.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I finally chose to just re-compute it.

@github-actions
Copy link

github-actions bot commented Sep 3, 2025

✅ Automated performance checks have passed on commit f01eb41d83d60e4d5ffa34af41047365feffd6b9 with the base branch dev.

Details

Performance tests 1st run output

No significative change in performance for tests:

Name Mean Median
loading 19.34ms -> 19.65ms (-0.305ms, z: 0.41196) 27.00ms -> 27.15ms
seeking 17.18ms -> 12.43ms (4.743ms, z: 1.29048) 10.95ms -> 10.95ms
audio-track-reload 25.91ms -> 25.82ms (0.084ms, z: 0.55896) 37.95ms -> 37.80ms
cold loading multithread 46.01ms -> 45.21ms (0.806ms, z: 14.42131) 67.80ms -> 66.60ms
seeking multithread 41.02ms -> 38.43ms (2.592ms, z: 0.53122) 10.05ms -> 10.10ms
audio-track-reload multithread 25.58ms -> 25.59ms (-0.012ms, z: 0.06707) 37.80ms -> 37.65ms
hot loading multithread 14.81ms -> 14.68ms (0.133ms, z: 5.56108) 21.60ms -> 21.30ms

@canalplus canalplus deleted a comment from github-actions bot Sep 3, 2025
@peaBerberian peaBerberian merged commit 0674ba9 into dev Sep 3, 2025
10 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) 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.

3 participants