ennuicastr / libavjs-webcodecs-polyfill

A polyfill for the WebCodecs API. No, really.
82 stars 8 forks source link

Make it work in a worker context #14

Closed martenrichter closed 1 year ago

martenrichter commented 1 year ago

I am feeding my Video- and AudioCodec from a Worker Thread, this PR should fix some exceptions, which occur during the initial loading of the polyfill. There may be further related issues may be present, these will be addressed in later PR, while testing the components. It would be nice, if you consider adding these changes.

Yahweasel commented 1 year ago

A couple things to fix:

  1. You left a .test.js in package.json. Fix it back to .min.js
  2. I don't want the polyfill to break on systems earlier than globalThis. Either add the globalthis polyfill, or polyfill it as (globalThis || window) yourself.
martenrichter commented 1 year ago

Sorry about 1. I thought I changed it back everywhere.... (so I will do that) Regarding 2: Using (globalThis || window) would it not also break in workers in these earlier systems? What about (globalThis || self || window) ?

Yahweasel commented 1 year ago

It already breaks on workers ;) . It's fine to add that too, I'm just principally concerned with not breaking on systems where it currently works.

martenrichter commented 1 year ago

In order to also potentially not harm node.js I added a polyfill. (not yet tested, will do it next weekend, or test it yourself). But also changes in libav.js are required for workers, it is buried in the last changes in the closed issue.

martenrichter commented 1 year ago

After getting the correct polyfill. This is now tested to be correctly loaded. At least I get the same anull error than last week. A PR for libav.js is coming soon to supply loading code in bundler context.