egui
egui copied to clipboard
Missing WASM setup docs related to ahash/getrandom
I was trying to setup egui for a WASM project, and it took about 15 minutes of searching to find that I had to manually add getrandom as a dependency for it to work on WASM:
[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = ["js"] }
If possible there should be clearer documentation for setting up on WASM, specifically for this issue. I had to look at commit 5514a8afda53c282d2be670bef657d5c7812d467 to find the solution.
Thanks!
is this something that ahash
crate should be fixing? ahash can provide an optional feature which toggles the js feature of getrandom.
the current method sounds more like a hack to me
reference: https://github.com/tkaitchuck/aHash/issues/59
It seems like this can be solved by not using the (default) runtime-rng
feature of ahash
. That is: if the egui crates has ahash = { version = "0.8", default-features = false, features = ["compile-time-rng", "std"] }
then there is no dependency on getrandom
.
…but we get a lot of other dependencies instead, which likely will increase compile times.
Maybe ahash
could have a fixed-seed
feature flag which doesn't require any dependencies (and doesn't protect against DOS attacks, which egui doesn't really care about anyways, and egui users can still opt-in to)
Looks this is fixed, thanks!