Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow usage on wasm32-unknown-unknown target #194

Merged
merged 6 commits into from
Sep 25, 2019

Conversation

RReverser
Copy link
Contributor

This PR allows to compile and use OxiPNG on wasm32-unknown-unknown target, thus fixes #157.

The changes are described in commit messages, but, as a short summary, two primary fixes are:

  • Avoiding call to Instant::now() in Deadline::new when no Timeout is set. This is required because Instant::now() panics on wasm32-unknown-unknown (as it tries to retrieve time, for which there is no generic Wasm syscall implementation), and so allows to initialise OxiPNG with default options (no timeout) while still allowing to use timeout on other platforms.
  • Trying all the combinations on the main thread when feature = "parallel" is unset. Threads proposal for Wasm is not finalised and will take time to be ready in mainstream implementation, so this is also important for OxiPNG to work on Wasm target.

This avoids a syscall to the time API when the result is ignored later anyway.

This allows to use the library with default options on wasm32-unknown-unknown, where the unimplemented syscall would panic otherwise.
We can drop the value manually, thus avoiding unwrap on each access.
If either `rayon` is already imported, then `rayon::prelude::*` should always resolve.
@RReverser RReverser mentioned this pull request Aug 24, 2019
Copy link
Owner

@shssoichiro shssoichiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good, sorry for the long time getting to it.

src/lib.rs Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebAssembly version?
2 participants