Repository navigation
Description
What are you trying to do
Someone asked for a "view only" SolidCraft: open a design to look at it (orbit, select, measure, section, maybe leave a note) without the modelling tools. I'd like that as part of the server edition in #19199. You run solidcraft-cli serve in a read-only mode, and it serves a small viewer app that has only the view controls and none of the modelling code. The server already has the whole kernel, so it can open and evaluate the design and send the browser just what it needs to draw it.
Today every way of looking at a design in the browser downloads the whole app:
?embed&open=<url>(Web app: open a design from a link, and an embed mode for other pages #6252) is already a read-only viewer: no ribbon, no saving. But it's the full web build underneath.- The desktop app has Open Read-Only, and
--read-only(Opening designs:--read-onlyopens the named designs read-only, also in an already running window #20834), but there you can still edit, you just can't save over the file. - The third-party team server in discussion A self-hosted team workspace around the SolidCraft web app (and a question about the name) #19513 has a viewer role, and it serves the stock web build too.
The full web build is big, and that's what keeps phones and tablets out. On upstream main at e060398 the main wasm is 183 MB (156 MB of code) plus a 141 MB compute worker. #23933 brought it down by about a quarter, but it's still well over 100 MB (#21085). I tried it on an old 2 GB Android tablet (NVIDIA Shield, Chromium 119):
- With the stock build the tab dies about 25 s into startup, while V8 is still compiling. Renderer memory hits about 750 MB.
- With everything built at
opt-level = "z"(113 MB of code) it only starts once the service worker isn't there to precache the 104 MB compute worker at the same moment. Startup still peaks at 550 to 680 MB. - Once it's running, idle is about 300 MB. One session died about 10 s into Extrude with what looks like an out-of-memory kill.
Someone who only wants to look at a part doesn't need any of the code that fills that memory: solidcore, the feature ops, the sketch solver, the cadmpeg codecs, the compute worker.
Who this helps:
- Phones and low-end tablets. There are open requests for mobile and tablet use (Sketching on Mobile Devices #15006, Native Android version with pen support #2828, A version for iPad OS #7891, discussion Running Solidcraft on a iPad/iPhone/iPhone Duo - disconnected from the Internet #6793). Looking at a design is the part that could work on those devices soon. Modelling on them is a much bigger job.
- Sharing a design by link. A link from a project page, a forum post or a chat should open fast, without a 100+ MB download.
- Design reviews. Reviewers need orbit, section, measure and markups (Review: markups beside the design, shown as pins in the 3D view #18800), not the Extrude tool.
- Print and shop previews. Checking a part before printing or quoting it only needs the shape and its sizes.
- Teams on a self-hosted server. Viewers get a role with no write path at all, not the editor with Save switched off.
- Anyone on a machine that can't run the full app, such as a classroom laptop, a shared computer or a 32-bit browser.
How you imagine it working
Three parts, all building on #19199.
1. serve --read-only (or a read-only token)
This is open question 3 in docs/server-edition.md on #19199 ("a second, read-only token ... would cover viewers"). In read-only mode:
- The HTTP API answers
GETonly (list, read, display data). There's noPUT, no delete and no new folders. - Network MCP sessions get an allowlist of read-only commands: open, inspect, measure, body topology, screenshot. They don't get the whole registry minus a few prefixes. That's what my review of Server edition: solidcraft-cli serve serves a folder of designs (a git checkout too) to the browser app and to agents over MCP #19199 asked for anyway: decide on the resolved command id, refuse anything not on the list, and keep out commands that reach outside the folder (
diagnostics.crash_reports,file.send_to_slicer). MCP and CLI: show for each command whether it reads or writes files, so a sandbox can allow only safe commands #23440 (marking which commands read or write files) would make the list easy to keep right. - Nothing is saved, exported or written anywhere. That makes read-only the safest thing
servecan do, so it might be a good first mode to ship.
2. A display-data endpoint
GET /api/display?path=part.sc opens the design on the server, evaluates it and answers with what a viewer draws: per-body triangle meshes with normals and colours, edges, a face and body id for each triangle (for picking), body and component names, the browser tree with visibility, and the bounding box. The server caches the result per document digest, so a second visitor doesn't evaluate the design again.
There's a good starting point already. file.save {preview: true} writes display meshes into the container (cache/preview.json and cache/preview.bin, solidcraft-preview/1). crates/design-preview reads them with no kernel, and the macOS Quick Look extension already orbits them (docs/design-container.md, "Provisional saved display"). The viewer needs a bit more than that cache keeps: edges, face ids for picking, and more than 100,000 triangles. So I'd treat this as a richer sibling of solidcraft-preview/1, with the same bounded, untrusted, display-only rules.
The native model cache (cache/model.json) isn't the right thing to send. It's exact B-rep that needs solidcore to tessellate, and it's tied to the build that wrote it.
Measuring goes back to the server as a read-only call, so distances and angles come from the exact geometry, not from triangles. Sections can be drawn on the client with a clipping plane.
3. A slim viewer app
A new web app, something like apps/solidcraft-viewer, built on ui-kit, viewport-egui and viewport-gpu. None of those depend on the engine, doc, kernel or solidcore. It has orbit, select, section, show and hide, measure through the server, and a link to open the design in the full app. Later it could also show markups (#18800).
From the per-crate sizes of the current main wasm (code before wasm-opt, about 200 MB in total), leaving out solidcore (65.8 MB), engine (17.7), doc (16.1), ui-egui (11.4), cadmpeg (about 16) and most of serde/schemars and solidcore's ops leaves something like 40 to 65 MB of code before wasm-opt. That's roughly 30 to 50 MB shipped, with no compute worker. Today it's 156 MB of code plus a 130 MB worker. That's an estimate from the name section, not a build, and I haven't checked how much of the 26 MB data section a viewer would keep.
The same app could open a .sc file from disk or from an ?open= link when it was saved with preview: true, using crates/design-preview. That gives a serverless, look-only fallback.
The open question is how much of the viewport interaction in ui-egui (selection, picking, the section tool) can move down into ui-kit and viewport-egui without pulling the engine along. Navigation already lives in ui-kit.
The cheaper alternative
A read-only UI flag in the full app means extending the ?embed viewer to hide every modelling tool. It's cheap to build, but it downloads exactly as much as the editor, so it doesn't help the devices that need this most. I'd only fall back to it if the slim viewer turns out to be too much work.
Activity