kornelski / dssim

Image similarity comparison simulating human perception (multiscale SSIM in Rust)
https://kornel.ski/dssim
GNU Affero General Public License v3.0
1.09k stars 70 forks source link

Can’t compile to WebAssembly #78

Closed surma closed 4 years ago

surma commented 4 years ago

The dssim CLI depends on the load_image crate which in turn relies on multiple *-sys crates. This makes compilation to WebAssembly fail. I am not sure why crate is compiling the CLI when I am only using it as a library, but it is.

Would it be feasible to separate the CLI and library into separate crates? Or maybe another solution is to put the CLI behind a (default-enabled) feature?

surma commented 4 years ago

After taking a closer look, I am now aware that you are using rayon, which probably also poses a challenge for the WebAssembly target. Not sure how feasible it is to make rayon optional? 🤔

kornelski commented 4 years ago

If you write a rayoff crate that exposes same methods, but serial, then I'll add it as an option.

kornelski commented 4 years ago

I've published lib-only crate https://lib.rs/dssim-core

surma commented 4 years ago

I've published lib-only crate lib.rs/dssim-core

That’s incredibly helpful. Thanks for that. I do like the idea of rayoff ;)

surma commented 4 years ago

Turns out, rayon already compiles against wasm. I am somewhat confident that your split just solved the entire problem.

Testing that now…

surma commented 4 years ago

Yup. This is all I needed. This library can now be used in WebAssembly 🎉 Thanks for the ultra-quick turnarnound!