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

Do not add failed push operations in the BufferedHistory #1323

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

peaBerberian
Copy link
Collaborator

This PR fixes a kind of rare issue that is tricky to reproduce that may happen after a QuotaExceededError is encountered when pushing a chunk to the audio and video SourceBuffer due to memory limitations.

In that situation, we could be left in the following scenario:

  1. We're loading a chunk and pushing it to the SourceBuffer
  2. The SourceBuffer throws a QuotaExceededError, generally this means that the device needs more memory to add that chunk
  3. The SegmentBuffer code still adds the chunk to its SegmentInventory (as it may still have been partially pushed to the SourceBuffer, we're not 100% sure of what happened on the lower-level code) and to that SegmentInventory's BufferedHistory.
  4. The stream code catches the error, try to remove some buffered data and retry to push the same chunk.
  5. Same QuotaExceededError
  6. The SegmentBuffer code agains, re do the whole SegmentInventory + BufferedHistory insertion thing for the same reasons
  7. The stream code re-catches the issue, here it takes more drastic measures, mainly reducing the amount of buffer that is built in advance.
  8. The stream code then checks if it re-needs the segment. However, it sees thanks to the BufferedHistory that it already tried to load chunk(s) from it two times, and that in those two times, the browser did not buffer it (there ignoring that there was a QuotaExceededError involved).
  9. The stream code thus assumes a browser/device issue with that segment, and loads the next segment instead.
  10. When it's time to decode the skipped chunk, the init code automatically seeks over it, which is good, but we would have preferred to actually load it.

This PR fixes the issue by clearly identifying in the SegmentInventory chunks whose push operation had an issue. Those are:

  1. never added to the BufferedHistory
  2. always re-loaded if they become needed again

We could also have not added them to the SegmentInventory altogether but I still think it's better to do it, as in the very rare chance that chunk still had been at least partially pushed, our logic would be more accurate.

@peaBerberian peaBerberian added the bug This is an RxPlayer issue (unexpected result when comparing to the API) label Nov 27, 2023
@peaBerberian peaBerberian added this to the 3.33.0 milestone Nov 27, 2023
@peaBerberian peaBerberian force-pushed the fix/gc-quotaexceedederror-skip-v3 branch from cd75250 to f5d78c8 Compare November 27, 2023 17:30
@peaBerberian peaBerberian force-pushed the fix/gc-quotaexceedederror-skip-v3 branch from f5d78c8 to 59aa510 Compare December 8, 2023 14:11
This commit fixes a kind of rare issue that is tricky to reproduce that
may happen after a `QuotaExceededError` is encountered when pushing a
chunk to the audio and video `SourceBuffer` due to memory limitations.

In that situation, we could be left in the following scenario:
  1. We're loading a chunk and pushing it to the `SourceBuffer`
  2. The `SourceBuffer` throws a `QuotaExceededError`, generally this
     means that the device needs more memory to add that chunk
  3. The SegmentBuffer code still adds the chunk to its `SegmentInventory`
     (as it may still have been partially pushed to the SourceBuffer,
     we're not 100% sure of what happened on the lower-level code) and
     to that `SegmentInventory`'s `BufferedHistory`.
  4. The stream code catches the error, try to remove some buffered data
     and retry to push the same chunk.
  5. Same QuotaExceededError
  6. The SegmentBuffer code agains, re do the whole `SegmentInventory` +
     `BufferedHistory` insertion thing for the same reasons
  7. The stream code re-catches the issue, here it takes more drastic
     measures, mainly reducing the amount of buffer that is built in
     advance.
  8. The stream code then check if it re-needs the chunk. However, it
     sees through the `BufferedHistory` that it already tried to load it
     two times, and that in those two times, the browser did not buffer
     it (there ignoring that there was a `QuotaExceededError` involved).
  9. The stream code thus assumes a browser/device issue with that
     segment, and loads the next one instead.
 10. When it's time to decode the skipped chunk, the RxPlayer
     automatically seek over it, which is good, but we would have
     prefered to actually log it.

This commit fixes the issue by clearly identifying in the
`SegmentInventory` chunks whose push operation had an issue. Those are:
  1. never added to the `BufferedHistory`
  2. always re-loaded if they become needed again

We could also have not added them to the `SegmentInventory` altogether
but I still think it's better to do it, as in the very rare chance that
chunk still had been at least partially pushed, our logic would be more
accurate.
@peaBerberian peaBerberian force-pushed the fix/gc-quotaexceedederror-skip-v3 branch from 59aa510 to 79ebbfc Compare December 11, 2023 13:56
@peaBerberian peaBerberian merged commit aa59594 into master Dec 11, 2023
2 of 3 checks passed
@peaBerberian peaBerberian mentioned this pull request Jan 24, 2024
@peaBerberian peaBerberian deleted the fix/gc-quotaexceedederror-skip-v3 branch February 7, 2024 17:49
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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants