dimforge / dimforge/bevy_rapier

WASM: `dyn PhysicsHooks` cannot be shared between threads safely

Open
#315 1 comment 0 reactions 0 assignees View on GitHub
A-Integration D-Difficult dependencies P-Low S-not-started
Dominant language
Rust
Stars
1.6k
Forks
282
PR merge metrics
No merged PRs in 30d

Description

Building for desktop works fine, but when trying to build with `trunk` for WASM, I'm getting a compiler error in `bevy-rapier2d`. The `wasm-bindgen` feature is enabled.

Bevy version: 0.9.1
Bevy_rapier2d version: 0.20.0

```
error[E0277]: `dyn PhysicsHooks` cannot be shared between threads safely
--> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rapier2d-0.17.0/src/geometry/narrow_phase.rs:695:74
|
695 | par_iter_mut!(&mut self.intersection_graph.graph.edges).for_each(|edge| {
| -------- ^-----
| | |
| _________________________________________________________________|________within this `[closure@/home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rapier2d-0.17.0/src/geometry/narrow_phase.rs:695:74: 695:80]`
| | |
| | required by a bound introduced by this call
696 | | let handle1 = nodes[edge.source().index()].weight;
697 | | let handle2 = nodes[edge.target().index()].weight;
698 | | let had_intersection = edge.weight.intersecting;
... |
775 | | }
776 | | });
| |_________^ `dyn PhysicsHooks` cannot be shared between threads safely
|
= help: within `[closure@/home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rapier2d-0.17.0/src/geometry/narrow_phase.rs:695:74: 695:80]`, the trait `Sync` is not implemented for `dyn PhysicsHooks`
= note: required because it appears within the type `&dyn PhysicsHooks`
note: required because it's used within this closure
--> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rapier2d-0.17.0/src/geometry/narrow_phase.rs:695:74
|
695 | par_iter_mut!(&mut self.intersection_graph.graph.edges).for_each(|edge| {
| ^^^^^^
note: required by a bound in `rayon::iter::ParallelIterator::for_each`
--> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.6.1/src/iter/mod.rs:369:30
|
369 | OP: Fn(Self::Item) + Sync + Send,
| ^^^^ required by this bound in `ParallelIterator::for_each`

````

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.