niutech / jxl.js

JPEG XL decoder in JavaScript using WebAssembly (WASM)
https://niutech.github.io/jxl.js/
Apache License 2.0
325 stars 17 forks source link

Multithread version doesn't seem to work on WebKit-powered browsers (like on iOS) #6

Open pmarreck opened 1 year ago

pmarreck commented 1 year ago

Impressive work! I tried it on various browsers, even the multithread version worked on anything modern BUT webkit-powered browsers (such as, unfortunately, ALL browsers on iOS). Is there a way to do multithread on webkit? (The non-multithread does seem to work fine.)

niutech commented 1 year ago

Which version of iOS/Safari? I don't have iOS devices, could you debug Safari on iOS and check what's the error in web inspector?

pboiski commented 1 year ago

I tried with Epiphany and it gave me the following error:

Screenshot_20221230_093149

niutech commented 1 year ago

It means that SharedArrayBuffer is not available in this browser - see the browser support - you have to use the single-thread version, I cannot do much with it.

pboiski commented 1 year ago

Ah, how stupid of me. I did manage to get webinspector going in the mean time. Tried it with an iPhone 6s running 15.7.2 and an iPhone X running 16.2. Both gave me the same error when browsing the multithreaded demo page: Schermafbeelding 2022-12-30 135335

niutech commented 1 year ago

It seems that iOS has strict limits for allocating memory for WebAssembly. I don't have Apple devices to test it, but what if you decrease values in new WebAssembly.Memory({initial:ep/65536,maximum:32768,shared:!0}) in jxl_decoder.min.js (ep=104857600)?

pboiski commented 1 year ago

Setting ep=26214400 and initial:ep/8192,maximum:16384 will get the demo page loading with no issues for me.

I also tried with a larger 2MB image but that wouldn't load on single or multi threaded (and gave no errors whatsoever).