The UI lags and becomes unresponsive for the full duration of a simulation when the configuration contains a large number of mechanisms.
The solver runs as a WASM module synchronously on the main thread, which blocks the UI while the simulation is executing.
Move the solver execution to a module Web Worker.
The WASM module is loaded via dynamic import, which works inside a module worker. Vite 7 also supports new Worker(new URL(...), { type: 'module' }) natively.
The mechanism configuration and solver results are plain JSON-serializable objects, so the structured-clone overhead of communicating between the main thread and worker should be relatively small.
The UI lags and becomes unresponsive for the full duration of a simulation when the configuration contains a large number of mechanisms.
The solver runs as a WASM module synchronously on the main thread, which blocks the UI while the simulation is executing.
Move the solver execution to a module Web Worker.
The WASM module is loaded via dynamic import, which works inside a module worker. Vite 7 also supports new Worker(new URL(...), { type: 'module' }) natively.
The mechanism configuration and solver results are plain JSON-serializable objects, so the structured-clone overhead of communicating between the main thread and worker should be relatively small.