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

Help / example running mozjpeg in a worker (comlink) #697

Closed
kasperkamperman opened this issue Sep 15, 2019 · 1 comment
Closed

Help / example running mozjpeg in a worker (comlink) #697

kasperkamperman opened this issue Sep 15, 2019 · 1 comment

Comments

@kasperkamperman
Copy link

kasperkamperman commented Sep 15, 2019

I'm trying to understand all the concepts regarding WebWorkers in combination with encoding.

As far as I understand in the example.html in the specific code folder (for example mozjpeg_enc) the encoding doesn't happen in a webworker.

How would I import the "mozjpeg_enc.js" in a worker.js and run that?

I looked for some information on comlink and found an article that shows it with ffmpeg (https://dev.to/chromiumdev/running-ffmpeg-with-wasm-in-a-web-worker-5gb5).

importScripts("https://cdn.jsdelivr.net/npm/comlinkjs@3.0.2/umd/comlink.js");
importScripts("mozjpeg_enc.js");
Comlink.expose(mozjpeg_enc);

This gives me the error "TypeError: undefined is not an Object. (evaluating 'prop in endpoint')"

Probably I overlook something really basic, hopefully, someone can give me a hint.
A small example or link to some resources would help really much.

In the "complex js-heavy web apps" talk some code is shown however it seems psuedo JS code, because I can't find it anywhere:
https://youtu.be/ipNW6lJHVEs?t=1215

@surma
Copy link
Collaborator

surma commented Oct 1, 2019

Yeah, this should work. Not sure why it doesn't. Can you put your demo in a Glitch or something?

@surma surma closed this as completed Dec 10, 2020
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

No branches or pull requests

2 participants