Skip to content

Prevent parallel wasm builds #461

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

Closed
wants to merge 1 commit into from

Conversation

bugQ
Copy link

@bugQ bugQ commented Mar 11, 2023

Attempting to target wasm with the parallel feature on fails because rayon does not natively support it.

Parallelism on WebAssembly is technically achievable through the Web Workers API, but until such functionality is stable, this should provide a better error message.

Attempting to target wasm with the parallel feature on fails because `rayon` does not natively support it.

Parallelism on WebAssembly is technically achievable through the Web Workers API, but until such functionality is stable, this should provide a better error message.
@bugQ bugQ force-pushed the disallow-parallel-wasm branch from 500071e to d92702e Compare March 12, 2023 22:48
@Vrixyz Vrixyz added P-Medium D-Medium question Further information is requested P-Low and removed P-Medium labels May 29, 2024
@Vrixyz
Copy link
Contributor

Vrixyz commented May 29, 2024

I believe since rayon-rs/rayon#1110 ; rayon has a synchronous fallback to work on web ; needs verification though.

@Master-Hash
Copy link

Master-Hash commented Jul 16, 2025

needs verification though

I confirm rapier.js with parallel feature with wasm-bindgen-rayon works on web.

Both multi thread with Web Workers, and single thread fallback works.

According to

// TODO: right now, the wasm version don't have the Send+Sync bounds.
// This is because these bounds are very difficult to fulfill if we want to
// call JS closures. Also, parallelism cannot be enabled for wasm targets, so
// not having Send+Sync isn't a problem.
/// User-defined functions called by the physics engines during one timestep in order to customize its behavior.
#[cfg(target_arch = "wasm32")]
pub trait PhysicsHooks {
/// Applies the contact pair filter.
fn filter_contact_pair(&self, _context: &PairFilterContext) -> Option<SolverFlags> {
Some(SolverFlags::COMPUTE_IMPULSES)
}
/// Applies the intersection pair filter.
fn filter_intersection_pair(&self, _context: &PairFilterContext) -> bool {
true
}
/// Modifies the set of contacts seen by the constraints solver.
fn modify_solver_contacts(&self, _context: &mut ContactModificationContext) {}
}

PhysicsHooks may not function, but I'm not its user anyway.

@bugQ
Copy link
Author

bugQ commented Jul 17, 2025

Awesome, sounds like this PR is not needed then.

@bugQ bugQ closed this Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D-Medium P-Low question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants