Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: better worker build #1033

Merged
merged 9 commits into from
Feb 2, 2021
Merged

chore: better worker build #1033

merged 9 commits into from
Feb 2, 2021

Conversation

brandonocasey
Copy link
Contributor

@brandonocasey brandonocasey commented Dec 10, 2020

Description

I wrote rollup-plugin-worker-factory for Mux.js so that we could support nodejs workers and browser workers using the same plugin. It has side benefits of:

  1. not needing a separate build target for workers that has to run before other builds
  2. We can share a rollup cache between the worker and main builds
  3. Worker code doesn't have to be wrapped in a strange function or export anything.
  4. The new rollup plugin is much more readable than our current plugin.
  5. We can support add a debug build for web workers that run in the same thread and not a WebWorker blob for debugging.

data.iv.byteOffset,
data.iv.byteLength / 4
);
self.onmessage = function(event) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer wrap in a function here, instead the code looks exactly as it would running on a web worker, inside of the main script body.

this.messageHandlers = new MessageHandlers(self, event.data.options);
return;
}
self.onmessage = function(event) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again no longer wrapped in a function.

@@ -13,7 +13,7 @@ import { MasterPlaylistController } from '../src/master-playlist-controller';
import SourceUpdater from '../src/source-updater';
import SyncController from '../src/sync-controller';
import TimelineChangeController from '../src/timeline-change-controller';
import Decrypter from 'worker!../src/decrypter-worker.worker.js';
import Decrypter from 'worker!../src/decrypter-worker.js';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slight change since we no longer pre-bundle the worker.

scripts/rollup.config.js Outdated Show resolved Hide resolved
src/transmuxer-worker.js Outdated Show resolved Hide resolved
@brandonocasey brandonocasey force-pushed the chore/better-worker-build branch from 80410f6 to 3422c1d Compare January 21, 2021 20:43
@brandonocasey brandonocasey force-pushed the chore/better-worker-build branch from 3422c1d to 0d6f722 Compare January 25, 2021 20:25
@brandonocasey brandonocasey force-pushed the chore/better-worker-build branch from 0d6f722 to f8bf2cf Compare January 25, 2021 20:26
@brandonocasey brandonocasey merged commit f0732af into main Feb 2, 2021
@brandonocasey brandonocasey deleted the chore/better-worker-build branch February 2, 2021 17:16
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