Skip to content

feat: add worker option for inline/main-thread runtime - #53

Open
hesam-oxe wants to merge 1 commit into
bilibili:mainfrom
hesam-oxe:feat/disable-worker-option
Open

feat: add worker option for inline/main-thread runtime#53
hesam-oxe wants to merge 1 commit into
bilibili:mainfrom
hesam-oxe:feat/disable-worker-option

Conversation

@hesam-oxe

Copy link
Copy Markdown

Added worker option to WebDemuxerOptions to allow disabling the
internal Worker for use inside Web Workers.

Changes

  • New worker option (default: true for backward compatibility)
  • When worker: false, no internal Worker is created
  • load() and non-streaming methods work in inline mode
  • Streaming methods throw clear error in inline mode

Usage

// Inside a Web Worker — use inline mode
const demuxer = new WebDemuxer({ worker: false });
await demuxer.load(file);
const packet = await demuxer.getAVPacket(0);

Added worker option to WebDemuxerOptions. When worker: false, no internal Worker is created, allowing safe use inside Web Workers. Streaming raises error in inline mode. Closes bilibili#51
@ForeverSc

Copy link
Copy Markdown
Collaborator

@hesam-oxe Thanks for the PR, but worker: false won't work as-is — getFromWorker() rejects when there's no worker, so getAVPacket() etc. will all fail. The inline wasm execution path is missing.

@hesam-oxe

Copy link
Copy Markdown
Author

@ForeverSc You're right — the inline wasm execution path is missing.

I'll need to understand how the WASM module is loaded and executed
in the worker to replicate that inline.

Could you point me to:

  1. Where the WASM module is initialized in the worker?
  2. Any existing inline/main-thread patterns in the codebase?

I'll update the PR with a proper inline implementation.

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.

2 participants