Skip to content

Run simulations in Safari on a single-threaded engine - #481

Merged
andeplane merged 4 commits into
mainfrom
claude/project-thread-rr9k2f
Nov 5, 2026
Merged

andeplane merged 4 commits into
mainfrom
claude/project-thread-rr9k2f

Conversation

@andeplane

@andeplane andeplane commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Requested by Anders Hafreager · project thread

This bumps lammps.js to 1.6.1, which adds the lammps.js/wasm-atomify-serial export (andeplane/lammps.js#12, released via #13). The vendored lammps-js wheel in pypi/ is updated to 1.6.1 to match.

Why

Safari showed "Safari is not supported for simulations". The engine is the KOKKOS/pthreads build, which needs SharedArrayBuffer, so the page has to be cross-origin isolated. Atomify gets that isolation from COEP credentialless, which Safari doesn't support. Switching to require-corp was tried before (69ca6e8) and backed out.

What

  • src/wasm/engineVariant.ts picks the build from the context: the threaded wasm-atomify build when crossOriginIsolated is true and SharedArrayBuffer exists, otherwise wasm-atomify-serial. That is the same package set without KOKKOS, a 21 MB module instead of 43 MB.
  • The proxy passes the variant to the worker in load (protocol version bumped to 3). The worker imports the matching module, and the adapter starts serial with no -k on -sf kk.
  • LammpsWeb.multithreaded is false on the serial engine. RunController then skips the KOKKOS preprocessing (suffix off and the kk-wrapped atom_style / pair_style hybrid) and doesn't inject the opt-in. Scripts that keep suffix kk still run, because LAMMPS falls back to the plain styles.
  • In the New Run modal, the Multithreading switch is disabled on the serial engine and reads "Not available in this browser. Simulations run on a single thread."
  • The Safari block and the "requires cross-origin isolation" error are removed. A page that can't be isolated now just runs single-threaded.
  • The help pages (requirements, troubleshooting, known limitations, multithreading, how simulations run) are updated, and the Safari-unsupported screenshot is dropped.
  • e2e: the isolation spec now checks that a page with service workers blocked loads lammps-atomify-serial and completes a run, and that Safari (webkit project) runs a simulation.
  • EXAMPLES_ENGINE=serial npm run test:examples runs the example smoke test on the serial engine the way the app does in Safari.

Testing

  • CI: build and smoke both pass.
  • Locally, tsc, eslint (0 errors), prettier and vitest run all pass (686 tests).
  • Example smoke test on the serial engine: 53/53 passed.
  • Both chromium tests in e2e/engine-isolation.spec.ts pass against vite build: the isolated threaded run and the non-isolated serial run of 2D LJ fluid.
  • Not run: real Safari/WebKit. Only Chromium is available in my sandbox.

🤖 Generated with Claude Code

https://claude.ai/code/session_01E2eZ9vB9rpavnjH7bPxkuK

Safari can't be cross-origin isolated (no COEP credentialless), so it has
no SharedArrayBuffer and can't run the KOKKOS/pthreads build. Instead of
blocking it, pick the engine build from the context: the threaded atomify
build when isolated, otherwise lammps.js's atomify-serial build (same
packages, no KOKKOS). The serial engine starts without -sf kk, scripts
skip the KOKKOS preprocessing, and the Multithreading switch is disabled
with an explanation. Help pages and e2e specs updated accordingly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2eZ9vB9rpavnjH7bPxkuK
@andeplane andeplane self-assigned this Nov 5, 2026

Copy link
Copy Markdown
Owner Author

build and smoke fail with "./wasm-atomify-serial" is not exported ... from package lammps.js. That's expected. This branch still pins lammps.js 1.5.1, and the export comes from andeplane/lammps.js#12, which will ship in the next lammps.js release (1.6.1). I'll bump lammps.js here once that is on npm. Until then, re-running CI won't help.


Generated by Claude Code

andeplane added a commit to andeplane/lammps.js that referenced this pull request Nov 5, 2026
<!-- claude-projects-attribution: {"github_login":"andeplane"} -->
_Requested by **Anders Hafreager** · [project
thread](https://claude.ai/code/project/chan_01G7VSoPZwxUhEt8N3Ft8nF9?thread=cmsg_01G7VSoPZwxUhEt8N3Ft8nF9GTqdMRwaTHD27RxAcG9jjW)_

This bumps `package.json` and `python/pyproject.toml` to 1.6.1, so
merging it publishes master to npm. That includes the
`wasm-atomify-serial` variant from #12, which Atomify needs to run
simulations in Safari (andeplane/atomify#481).

LAMMPS stays at stable_30Sep2026, the same as 1.6.0. The move to
stable_30Sep2026_update1 (#10) is on hold because update1 crashes three
moltemplate PPPM examples. #10 will ship as 1.6.2.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01E2eZ9vB9rpavnjH7bPxkuK)_

Co-authored-by: Claude <noreply@anthropic.com>
…rial engine

EXAMPLES_ENGINE=serial runs the example smoke test on the atomify-serial
build the way the app does in Safari.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2eZ9vB9rpavnjH7bPxkuK
Built with `python -m build --wheel` from a git archive of lammps.js
master at 1.6.1 (python/), replacing the 1.5.1 wheel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2eZ9vB9rpavnjH7bPxkuK
@andeplane
andeplane marked this pull request as ready for review November 5, 2026 12:27
@andeplane
andeplane merged commit 703c6e9 into main Nov 5, 2026
3 checks passed
@andeplane
andeplane deleted the claude/project-thread-rr9k2f branch November 5, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants