UprootLabs / poly-flif

:camera: A poly-fill for the FLIF image format.
https://uprootlabs.github.io/poly-flif/
Other
244 stars 11 forks source link

Decode in web worker #27

Closed FallingSnow closed 7 years ago

FallingSnow commented 7 years ago

Is it possible to decode a flif in a web worker? I'm using canvas-webworker with webpack in a web worker but keep running into this issue: Cannot set property 'PolyFlif' of undefined.

The referenced line is:

  }var ic = !1;c.noInitialRun && (ic = !1);c.noExitRuntime = !0;jb();window.PolyFlif = c.PolyFlif.extend("PolyFlif", { __construct: function __construct(b) {

at window.PolyFlif.

I've tried adding let window = self before importing the script but it seems to have no effect.

hrj commented 7 years ago

I haven't tested / developed support for webworkers yet. It shouldn't be too complicated, but I don't think it will be very trivial either.

Might be sometime before I get to this. PRs welcome :smile:

FallingSnow commented 7 years ago

I actually did manage to get it to work by adding var window = self to the beginning of the PolyFlif.js file itself and removing the section referring to document. However it doesn't seem to manipulate the canvas correctly when used with canvas-webworker. All the imagedata is set to 0. Since this is the only library that allows me to use a canvas in webworkers I feel I've hit a dead end.

FallingSnow commented 7 years ago

I have finally got it done using https://github.com/SaschaNaz/libflif.js but it is

hrj commented 7 years ago

I am trying to get back into development but, FWIW, I am stuck at getting the latest emscripten to compile on Linux :confounded:

How I would approach this without modifying the library: