Skip to content

Turn the transmuxing worker back off: it is webpack-only - #16

Merged
ralyodio merged 1 commit into
mainfrom
fix-worker-webpack-only
Aug 30, 2026
Merged

Turn the transmuxing worker back off: it is webpack-only#16
ralyodio merged 1 commit into
mainfrom
fix-worker-webpack-only

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

Every stream stopped playing after #15. enableWorker: true was copied from media-streamer's live TV player, and it cannot be copied.

Why

mpegts.js builds its worker by stringifying __webpack_modules__ — webpack's internal module registry — in utils/webworkify-webpack.js:

var sources = { main: __webpack_modules__ }
...
var blob = new self.Blob([src], { type: 'text/javascript' })
var worker = new self.Worker(URL.createObjectURL(blob))

That global exists in media-streamer, which is Next.js and therefore webpack. This bundle is built by Bun, where there is no such global, so the worker it assembles is broken.

Why it was silent

Transmuxer does guard it:

if (config.enableWorker && typeof (Worker) !== 'undefined') {
    try { this._worker = work(require.resolve('./transmuxing-worker')); ... }
    catch (error) { /* fallback to inline transmuxing */ }
}

But only a synchronous throw reaches that catch. A Worker that constructs from a blob whose body then fails is an asynchronous failure: nothing throws, nothing falls back, no init segment ever arrives, and the player reports no error at all. Not a dropped frame, not a message the reader can act on — just a channel that does nothing.

Scope of the revert

One line. Everything else in #15 came from the television's profile, which had been running in production for weeks — stash on at 384KB, chasing off, the cleanup bounds, lazyLoad off. enableWorker was the only setting that had never run anywhere except under webpack, which is why it is the only one reverted.

Untouched: the restart-budget fix (refill on playing) that stops streams dying after a minute or two, and fullscreen + sound on Play.

Test

The test that asserted the worker was on now asserts it is off and carries the reason, so nobody re-enables it without first changing how this file is bundled. 939 pass. vendor-mpegts.js rebuilt — enableWorker:!1, no enableWorker:!0.

🤖 Generated with Claude Code

https://claude.ai/code/session_01S5KxNHPQPY9Do9eWfJnGP4

Every stream stopped playing. `enableWorker: true` was copied from
media-streamer's live TV player in the previous commit, and it cannot be
copied.

mpegts.js builds its worker by stringifying `__webpack_modules__` --
webpack's internal module registry -- in `utils/webworkify-webpack.js`. That
global exists in media-streamer, which is Next.js and therefore webpack.
This bundle is built by Bun, where there is no such global, so the worker it
assembles is broken.

It then fails in the worst available way. `Transmuxer` does wrap the worker
setup in a try/catch and fall back to inline transmuxing, but only a
SYNCHRONOUS throw reaches that catch. A Worker that constructs from a blob
whose body then fails is an asynchronous failure: nothing throws, nothing
falls back, no init segment ever arrives, and the player sits there having
reported no error at all -- so it is not even a message the reader can act
on, just a channel that does nothing.

Everything else in that commit came over from the television's profile,
which had been running in production for weeks: stash on at 384KB, chasing
off, the cleanup bounds, lazyLoad off. This was the single line that had
never run anywhere except under webpack, which is why it is the only one
reverted. The restart-budget fix -- the one that stops streams dying after a
minute or two -- is untouched, as is fullscreen on Play.

The test that asserted the worker was on now asserts it is off, and carries
the reason so nobody re-enables it without changing how this file is bundled.

939 tests pass. `vendor-mpegts.js` rebuilt.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S5KxNHPQPY9Do9eWfJnGP4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant