-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Problem
I am using async-compat
in order to use the reqwest
HTTP client inside of bevy
's task pools. This works as expected in a native build, but for wasm32-unknown-unknown
, we encounter panics when async-compat
tries to spawn a thread here.
Solution
For my use case, I think it's actually fine to just remove async-compat
in WASM builds, because reqwest
doesn't depend on tokio
in WASM; it uses a Javascript HTTP client through wasm-bindgen
.
So I'm trying to figure out the best way to handle this. I'm imagining that conditional compilation will be the most seamless way of removing async-compat
in WASM builds. Do the maintainers think it would make sense to add that conditional compilation directly to async-compat
? It might not make sense for all use cases, but I think it would be a shame for many people to have to solve this same problem independently.
And more practically speaking, I'm not sure exactly what the changes would need to be. My best guess is we could just put a #[cfg(not(feature = "disable"))]
on any callers of get_runtime_handle
. But maybe there's more to it.
Please let me know what you think. I might attempt this on a fork soon to see if it works for my application.