Skip to content

Commit

Permalink
Deprecate manual brotli decompression
Browse files Browse the repository at this point in the history
It doesn't have much benefit but comes with
a maintenance cost as we either need to keep
patching upstream's js implementation for use in
JSO — which also bloats binary size by including
two copies of brotli and its default dict — or
use the C implemntation from JS which requires boilerplate
in both C and JS and also additional JS polyfills to keep
e.g. the fontname extraction working.

The browser's in-built support for Content-Encoding
is more felxible, faster and simpler to use.

Cherry-picked from: libass@e459c8e
  • Loading branch information
TheOneric authored and dmitrylyzo committed Mar 22, 2024
1 parent f373e10 commit bde0b95
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,16 @@ Adjusting `prescaleFactor`, `prescaleHeightLimit` and `maxRenderHeight` to lower
the rendering canvas can work around this at the expense of visual quality.


### Brotli Compressed Subtitles
The SubtitleOctopus allow the use of compressed subtitles in brotli format,
saving bandwidth and reducing library startup time

To use, just run: `brotli subFile.ass` and use the .br result file with the subUrl option
### Brotli Compressed Subtitles (DEPRECATED)
Manual support for brotli-compressed subtitles is tentatively deprecated
and may be removed with the next release.

Instead use HTTP's `Content-Encoding:` header to transmit files compressed and
let the browser handle decompression before it reaches JSO. This supports more
compression algorithms and is likely faster.
Do not use a `.br` file extension if you use `Content-Ecoding:` as this will
conflict with the still existing manual support which tries to decompress any data
with a `.br` extension.

## How to build?

Expand Down
8 changes: 7 additions & 1 deletion src/pre-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ function isBrotliFile(url) {
len = url.length;
}

return url.endsWith(".br", len);
if (url.endsWith(".br", len)) {
console.warn("Support for manual brotli decompression is tentatively deprecated and "
+ "may be removed with the next release. Instead use HTTP's Content-Encoding.")
return true;
}

return false;
}

Module = Module || {};
Expand Down

0 comments on commit bde0b95

Please sign in to comment.