Skip to content

Commit c975a29

Browse files
committed
Drop deprecated support for manual brotli decompression
It doesn't have much benefit but comes with a maintenance cost. Instead the browser-inbuilt support for HTTP's Content-Encoding: header can beu sed instead to let the browser handle decompression. This will also work for more formats than just brotli.
1 parent cf04e03 commit c975a29

7 files changed

Lines changed: 5 additions & 61 deletions

File tree

Makefile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ $(DIST_DIR)/lib/libexpat.a: build/lib/expat/configured
4747
$(JSO_MAKE) install
4848

4949
# Brotli
50-
build/lib/brotli/js/decode.js: build/lib/brotli/configured
51-
build/lib/brotli/js/polyfill.js: build/lib/brotli/configured
5250
build/lib/brotli/configured: lib/brotli $(wildcard $(BASE_DIR)build/patches/brotli/*.patch)
5351
$(call PREPARE_SRC_PATCHED,brotli)
5452
touch build/lib/brotli/configured
@@ -167,24 +165,21 @@ EMCC_COMMON_ARGS = \
167165

168166
dist: src/subtitles-octopus-worker.bc dist/js/subtitles-octopus-worker.js dist/js/subtitles-octopus-worker-legacy.js dist/js/subtitles-octopus.js dist/js/COPYRIGHT dist/js/default.woff2
169167

170-
dist/js/subtitles-octopus-worker.js: src/subtitles-octopus-worker.bc src/pre-worker.js src/SubOctpInterface.js src/post-worker.js build/lib/brotli/js/decode.js
168+
dist/js/subtitles-octopus-worker.js: src/subtitles-octopus-worker.bc src/pre-worker.js src/SubOctpInterface.js src/post-worker.js
171169
mkdir -p dist/js
172170
emcc src/subtitles-octopus-worker.bc $(OCTP_DEPS) \
173171
--pre-js src/pre-worker.js \
174-
--pre-js build/lib/brotli/js/decode.js \
175172
--post-js src/SubOctpInterface.js \
176173
--post-js src/post-worker.js \
177174
-s WASM=1 \
178175
-s EVAL_CTORS=1 \
179176
$(EMCC_COMMON_ARGS)
180177

181-
dist/js/subtitles-octopus-worker-legacy.js: src/subtitles-octopus-worker.bc src/polyfill.js src/pre-worker.js src/SubOctpInterface.js src/post-worker.js build/lib/brotli/js/decode.js build/lib/brotli/js/polyfill.js
178+
dist/js/subtitles-octopus-worker-legacy.js: src/subtitles-octopus-worker.bc src/polyfill.js src/pre-worker.js src/SubOctpInterface.js src/post-worker.js
182179
mkdir -p dist/js
183180
emcc src/subtitles-octopus-worker.bc $(OCTP_DEPS) \
184181
--pre-js src/polyfill.js \
185-
--pre-js build/lib/brotli/js/polyfill.js \
186182
--pre-js src/pre-worker.js \
187-
--pre-js build/lib/brotli/js/decode.js \
188183
--post-js src/SubOctpInterface.js \
189184
--post-js src/post-worker.js \
190185
-s WASM=0 \

Makefile_licence

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
all: dist/license/all
66

77
LIB_LICENSES := brotli expat freetype fribidi fontconfig harfbuzz libass
8-
LIB_LICENSES_FINDOPT_brotli := -path ./research -prune -false -o ! -path ./js/decode.min.js
8+
LIB_LICENSES_FINDOPT_brotli := -regex \./c/.+
99
LIB_LICENSES_FINDOPT_expat := -path ./expat/fuzz -prune -false -o
1010
LIB_LICENSES_FINDOPT_freetype := -path ./src/tools -prune -false -o
1111
LIB_LICENSES_FINDOPT_fribidi := -path ./bin -prune -false -o

README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,6 @@ simply will not draw anything in canvas, mostly on low end devices.
177177
**WARNING: Experimental, not stable and not working in some browsers**
178178

179179

180-
### Brotli Compressed Subtitles (DEPRECATED)
181-
Manual support for brotli-compressed subtitles is tentatively deprecated
182-
and may be removed with the next release.
183-
184-
Instead use HTTP's `Content-Encoding:` header to transmit files compressed and
185-
let the browser handle decompression before it reaches JSO. This supports more
186-
compression algorithms and is likely faster.
187-
Do not use a `.br` file extension if you use `Content-Ecoding:` as this will
188-
conflict with the still existing manual support which tries to decompress any data
189-
with a `.br` extension.
190-
191180
## How to build?
192181

193182
### Dependencies

build/patches/brotli/0001-fix-brotli-js-for-webworkers.patch

Lines changed: 0 additions & 10 deletions
This file was deleted.

build/patches/brotli/0002-upstream_Enable-install-with-emscripten.patch renamed to build/patches/brotli/0001-upstream_Enable-install-with-emscripten.patch

File renamed without changes.

src/post-worker.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,7 @@ self.freeTrack = function () {
116116
*/
117117
self.setTrackByUrl = function (url) {
118118
var content = "";
119-
if (isBrotliFile(url)) {
120-
content = Module["BrotliDecode"](readBinary(url))
121-
} else {
122-
content = read_(url);
123-
}
119+
content = read_(url);
124120
self.setTrack(content);
125121
};
126122

src/pre-worker.js

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,6 @@ function makeCustomConsole() {
3232
return console;
3333
}
3434

35-
/**
36-
* Test the subtitle file for Brotli compression.
37-
* @param {!string} url the URL of the subtitle file.
38-
* @returns {boolean} Brotli compression found or not.
39-
*/
40-
function isBrotliFile(url) {
41-
// Search for parameters
42-
var len = url.indexOf("?");
43-
44-
if (len === -1) {
45-
len = url.length;
46-
}
47-
48-
if (url.endsWith(".br", len)) {
49-
console.warn("Support for manual brotli decompression is tentatively deprecated and "
50-
+ "may be removed with the next release. Instead use HTTP's Content-Encoding.")
51-
return true;
52-
}
53-
54-
return false;
55-
}
56-
5735
Module = Module || {};
5836

5937
Module["preRun"] = Module["preRun"] || [];
@@ -64,11 +42,7 @@ Module["preRun"].push(function () {
6442

6543
if (!self.subContent) {
6644
// We can use sync xhr cause we're inside Web Worker
67-
if (isBrotliFile(self.subUrl)) {
68-
self.subContent = Module["BrotliDecode"](readBinary(self.subUrl))
69-
} else {
70-
self.subContent = read_(self.subUrl);
71-
}
45+
self.subContent = read_(self.subUrl);
7246
}
7347

7448
if (self.availableFonts && self.availableFonts.length !== 0) {

0 commit comments

Comments
 (0)