webp-hero icon indicating copy to clipboard operation
webp-hero copied to clipboard

Handle delay when intialising wasm module

Open louisfoster opened this issue 1 year ago • 2 comments

If you run decode immediately after creating the WebpMachine, in some browsers this will cause an error like: Module.asm is undefined. This is because the wasm module is still loading. I fixed this in my code by adding a short delay after creating WebpMachine, however it would be cleaner if there was a way (such as promise/callback) to ensure the module has loaded, or force the decode function to wait.

I will attempt to look into this when I have time.

louisfoster avatar Sep 16 '22 10:09 louisfoster

hello! thanks for contributing! this sounds like a serious issue you've raised, we'd certainly like to solve it as properly as we can.

if you want to dig into the code:

  • be aware of the new work in the conditionally branch, which we intend to merge and release soon
  • this branch introduces a new conditional loader and easier html-only installation instructions
  • see the new readme installation instructions
  • see the new conditionally.ts script
  • we'd be happy to have your review

chase-moskal avatar Sep 16 '22 19:09 chase-moskal

i'll add: hopefully i'll have some time in the next couple weeks to merge conditionally, and either investigate this particular issue and/or review any contributions. cheers :beers:

chase-moskal avatar Sep 16 '22 19:09 chase-moskal