The win scales with size but the risk surface (LRU, stitching, the swap,
a worker) is constant, so there is a floor below which this is all cost.
The threshold is deliberately the size above which the viewer already stops
persisting the source to IndexedDB: above it the source is always
SharedArrayBuffer-backed, so handing it to the compression worker is
zero-copy. Gating lower would drag in the IndexedDB-restore path, which
would hand the worker a plain ArrayBuffer and pay a full structured clone
on every cache restore.
Whether compressing
byteLengthis worth it.The win scales with size but the risk surface (LRU, stitching, the swap, a worker) is constant, so there is a floor below which this is all cost. The threshold is deliberately the size above which the viewer already stops persisting the source to IndexedDB: above it the source is always SharedArrayBuffer-backed, so handing it to the compression worker is zero-copy. Gating lower would drag in the IndexedDB-restore path, which would hand the worker a plain ArrayBuffer and pay a full structured clone on every cache restore.