image: Uncaught (in promise) RuntimeError: unreachable
Hi, I am trying to use image and imageproc functions but keep getting in both cases a runtime error mentioning unreacheable. Any clues why this could be? I am compiling my code into wasm using cargo/wasm-pack. Thank you!
example:
let w = 200;
let h = 200;
let img = ImageBuffer::from_fn(w, h, |x, y| {
if (x + y) % 3 == 0 {
image::Rgba([0, 0, 0, 255])
} else {
image::Rgba([255, 255, 255, 255])
}
});
img.save("out.png").unwrap();

About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 15 (2 by maintainers)
@birdlavv You can copy the code here: https://crates.io/crates/console_error_panic_hook
Aha! It the hook produces:
panicked at 'called `Result::unwrap()` on an `Err` value: IoError(Error { kind: Unsupported, message: "operation not supported on this platform" })', src/lib.rs:20:25
After removing the
img.save("out.png").unwrap();
line it ran successfully!I believe this is because WASM does not have access to the filesystem. Thanks @zhyd1997! Bounty paid & closed.
Apologies @zhyd1997, I was unable to get a working WASM package built with those specific versions of rustup and cargo and your PR.
I’ve made a reproduction repo here: https://github.com/birdlavv/image-rs-1471-reproduction