Image: WASM support: JPEG import panics because rayon is not supported yet

Created on 7 Mar 2019  路  4Comments  路  Source: image-rs/image

I'm getting the following panic on a WebAssembly (WASM) binary when trying to load a JPG image from memory image::load_from_memory with rust v1.35:

panicked at 'called `Result::unwrap()` on an `Err` value: ThreadPoolBuildError { kind: IOError(Custom { kind: Other, error: StringError("operation not supported on wasm yet") }) }', src/libcore/result.rs:997:5

PNG and GIF works.

Would it be possible to include a switch in the image::load_from_memory API that disables rayon in the JPEG decoder? So we could work around this until rayon fully supports WASM as well.

(related: #703)

dependency enhancement question

Most helpful comment

@acidicX the Cargo.toml for the image crate is specifically written so that you can disable the feature in your own Cargo.toml. Specifically, "jpeg_rayon" is an option feature on this crate that is enabled by default but can be turned off by passing:

image = { version = "0.21.0", default-features = false, features = ["jpeg"] } 

All 4 comments

Not sure if this is the same issue that you're having, but I was encountering a similar issue with using image in WASM that I resolved by disabling the "jpeg_rayon" feature.

@jashephe cool, thanks for the hint. But I cannot override this in my own Cargo.toml, right? Right now I'm using the image crate. So I would have to remove it in image's Cargo.toml and build image myself?
(sorry, still a bit of a n00b in Rust)

@acidicX the Cargo.toml for the image crate is specifically written so that you can disable the feature in your own Cargo.toml. Specifically, "jpeg_rayon" is an option feature on this crate that is enabled by default but can be turned off by passing:

image = { version = "0.21.0", default-features = false, features = ["jpeg"] } 

This seems to be resolved to the author's expectations, judging by the reaction. I'm going to close this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fungos picture fungos  路  5Comments

Horki picture Horki  路  7Comments

newpavlov picture newpavlov  路  7Comments

aschampion picture aschampion  路  3Comments

fintelia picture fintelia  路  8Comments