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

WASM support #32

Closed
arendjr opened this issue Nov 24, 2024 · 5 comments · Fixed by #34
Closed

WASM support #32

arendjr opened this issue Nov 24, 2024 · 5 comments · Fixed by #34
Labels
feature New feature or request

Comments

@arendjr
Copy link

arendjr commented Nov 24, 2024

Do you think it might be possible to support WebAssembly as a target for papaya? Currently, it appears broken due to missing support in the atomic-wait dependency.

@ibraheemdev
Copy link
Owner

Hmm yes I think we can get rid of the atomic-wait dependency as we have an internal parker. Is that the only blocker?

@ibraheemdev ibraheemdev added the feature New feature or request label Nov 27, 2024
@arendjr
Copy link
Author

arendjr commented Nov 27, 2024

I think it is, but I haven't dug too deep. I see seize is also written by you, and its only dependency (libc) is already optional, so that'll probably just work. Serde certainly shouldn't be a problem. I have only briefly checked if you use std features that may be problematic on WASM. Most of it just works, but there are a few edge cases. Spawning threads is generally off the table, but I think your use of threads::current() is probably fine. After all, the docs say:

The thread::current function is available even for threads not spawned by the APIs of this module.

Locks and atomics should just work AFAIK, and will just assume you're in a single-threaded context anyway (at least for the wasm32-unknown-unknown target).

For Biome I wrote a papaya shim last night: biomejs/biome@3e350f9
But if we can get rid of it, I would be most happy. I'm not that comfortable with writing unsafe myself, and I think there may be an unsoundness in my shim when you take a reference to a value in the map and then mutate the map while hanging onto the reference. That's probably not a big deal for our use case, but I'd rather avoid it if we can.

@ibraheemdev
Copy link
Owner

Let me know if there's anything else I can do to help with this, I will cut a release soon.

@arendjr
Copy link
Author

arendjr commented Nov 28, 2024

Thanks a lot!

@arendjr
Copy link
Author

arendjr commented Nov 28, 2024

Just confirmed with your latest Git version, it compiles and appears to work fine 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants