image
image copied to clipboard
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();
![Screenshot 2021-05-04 at 16 31 33](https://user-images.githubusercontent.com/3520378/117033784-9fef6580-acfa-11eb-8dfa-59d2b55227fe.png)
I tried fixing the link but it appears to not have been uploaded successfully. Could you have a look and ensure that the image causing the error is available?
Hi, thanks for looking into this. I just updated my initial comment.
Weird, core::option::expect_none_failed
is not what I would expect in a stacktrace that ends with unreachable
. It seems like an assertion triggered (possibly this one) but the wasm compilation translates this to unreachable
somehow. Did you compile with panic=abort
?
No, just wasm-pack build --target web
Issue Status: 1. Open 2. Started 3. Submitted 4. Done
This issue now has a funding of 40.028 USD (40.0 USD @ $1.0/USD) attached to it.
- If you would like to work on this issue you can 'start work' on the Gitcoin Issue Details page.
- Want to chip in? Add your own contribution here.
- Questions? Checkout Gitcoin Help or the Gitcoin's Discord
- $4,662,632.83 more funded OSS Work available on the Gitcoin Issue Explorer
Issue Status: 1. Open 2. Started 3. Submitted 4. Done
Work has been started.
These users each claimed they can complete the work by 1 month from now. Please review their action plans below:
1) zhyd1997 has started work.
try cargo 1.56.0 (4ed5d137b 2021-10-04)
and ustup 1.24.3 (ce5817a94 2021-05-31)
Learn more on the Gitcoin Issue Details page.
Issue Status: 1. Open 2. Started 3. Submitted 4. Done
Work for 40.028 USD (40.0 USD @ $1.0/USD) has been submitted by:
@birdlavv please take a look at the submitted work:
- PR by @zhyd1997
- Learn more on the Gitcoin Issue Details page
- Want to chip in? Add your own contribution here.
- Questions? Checkout Gitcoin Help or the Gitcoin's Discord
- $4,662,201.83 more funded OSS Work available on the Gitcoin Issue Explorer
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
@birdlavv
So what're versions of rustup
and cargo
you used?
And node -v
?
Here is mine:
Sorry @zhyd1997 for the miscommunication, I was unable to get the build working- after I had installed the versions you specified.
Here are my versions:
![Screen Shot 2022-02-03 at 7 51 31 PM](https://user-images.githubusercontent.com/25445516/152459351-3004f683-71e8-4d6b-86cb-7be7f63297bc.png)
change your code like so, and reproduce as README described.
![Screen Shot 2022-02-04 at 10 04 10](https://user-images.githubusercontent.com/31362988/152460403-fd7b84cf-afc4-45c1-8888-d637bd94944c.png)
![Screen Shot 2022-02-04 at 10 04 42](https://user-images.githubusercontent.com/31362988/152460433-85fb9feb-53dd-4fb6-9cb8-5a72aca2b09a.png)
@birdlavv You can copy the code here: https://crates.io/crates/console_error_panic_hook
Issue Status: 1. Open 2. Started 3. Submitted 4. Done
The funding of 40.028 USD (40.0 USD @ $1.0/USD) attached to this issue has been approved & issued to @zhyd1997.
- Learn more on the Gitcoin Issue Details page
- Questions? Checkout Gitcoin Help or the Gitcoin's Discord
- $4,659,439.65 more funded OSS Work available on the Gitcoin Issue Explorer
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.