Commit d972a23
committed
fix: recover from QuotaExceededError by evicting back buffer and retrying append
When a SourceBuffer append throws QuotaExceededError, intercept the error
before it propagates, evict the minimum number of back buffer segments
needed to fit the new data, and retry the append with the original data
still in memory — avoiding the re-download loop that plagues hls.js
upstream (#6776, #6711).
Eviction uses stats.loaded (actual bytes received, always populated after
fragment completion) rather than frag.byteLength (which depends on
stats.total from Content-Length and may be 0 during progressive loading
or with chunked transfer), so the calculation is reliable regardless of
how segments are served.
A class-level _quotaEvictionPending flag per SourceBuffer type prevents
progressive loading chunks from each independently triggering eviction
or emitting BUFFER_FULL_ERROR. The first QuotaExceededError triggers
eviction; subsequent errors on the same type piggyback by queuing retries
behind the pending remove. If eviction + retry fails, falls through to
the existing BUFFER_FULL_ERROR path.
Changes:
- buffer-controller: on QuotaExceededError, calculate eviction target
and queue a remove + retry append instead of emitting an error
- buffer-controller: add _quotaEvictionPending flag gating per type
- buffer-controller: add getQuotaEvictionFlushOp that clears the
pending flag on complete/error
- fragment-tracker: add getBackBufferEvictionEnd() which walks buffered
fragments oldest-first accumulating byte sizes to find the minimum
eviction point
- buffer-operation-queue: add insertNext() to queue operations after
the current one for remove-then-retry sequencing1 parent 7a45b89 commit d972a23
3 files changed
Lines changed: 172 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
121 | 127 | | |
122 | 128 | | |
123 | 129 | | |
| |||
853 | 859 | | |
854 | 860 | | |
855 | 861 | | |
| 862 | + | |
856 | 863 | | |
857 | 864 | | |
858 | 865 | | |
| |||
900 | 907 | | |
901 | 908 | | |
902 | 909 | | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
903 | 950 | | |
904 | 951 | | |
905 | 952 | | |
| |||
914 | 961 | | |
915 | 962 | | |
916 | 963 | | |
917 | | - | |
918 | | - | |
919 | | - | |
920 | | - | |
921 | | - | |
| 964 | + | |
922 | 965 | | |
923 | | - | |
| 966 | + | |
924 | 967 | | |
925 | 968 | | |
926 | 969 | | |
| |||
971 | 1014 | | |
972 | 1015 | | |
973 | 1016 | | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
974 | 1044 | | |
975 | 1045 | | |
976 | 1046 | | |
| |||
1198 | 1268 | | |
1199 | 1269 | | |
1200 | 1270 | | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
1201 | 1291 | | |
1202 | 1292 | | |
1203 | 1293 | | |
| |||
1940 | 2030 | | |
1941 | 2031 | | |
1942 | 2032 | | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
1943 | 2039 | | |
1944 | 2040 | | |
1945 | 2041 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
82 | 90 | | |
83 | 91 | | |
84 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
482 | 482 | | |
483 | 483 | | |
484 | 484 | | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
485 | 547 | | |
486 | 548 | | |
487 | 549 | | |
| |||
0 commit comments