Skip to Content
Octapus

First-screen snapshot

What the snapshot stores, why it holds no geometry, and how a device turns it into a screen.

The first-screen snapshot (app.ofrm) is your app's first screen recorded at build time, so a device can show it before any JavaScript runs. It is the native counterpart of server-rendered HTML: content the user sees immediately, which your app's code takes over later.

What it stores

StoredWhy
Your app's first commit, as Octane produced itThe exact element tree and text your first render creates
Scoped <style> sheets from your componentsSo styles that arrive with modules are in place
Each element's computed style, for light and darkNo CSS cascade on device; dark mode is ready too
Which elements depend on the viewportOnly those are restyled on device
A hash of app.hbcTies the snapshot to the bytecode it came from

It does not store positions or sizes. Text measurement differs between macOS and iOS, and between a phone and a tablet, so the snapshot is laid out on the device. That is what lets one snapshot serve every native target and every screen size.

Viewport-dependent styles

Media queries and viewport units mean an element's style can depend on the screen. While baking, Octapus styles your tree at a set of reference sizes plus both sides of every width, height and aspect-ratio breakpoint in your media queries, in portrait and landscape, and marks every element whose style changes. On device, only those elements are restyled for the real viewport. If the page itself (html, body, the root element) depends on the viewport, the whole snapshot is restyled.

--viewport sets the reference size used for that check. It does not fix the size your screen is drawn at.

On the device

app.ofrm ─▶ apply the first commit ─▶ attach baked styles (light or dark)
         ─▶ restyle viewport-dependent elements ─▶ lay out with device fonts at the real size
         ─▶ draw: one pass over the rows, one native view per drawn element

The last step is deliberately simple. Rows come in tree order, parents before children, and each row carries its paint style, text and frame, so drawing is "create view, apply style, set frame, add to parent" per row. No lookups, no cascade and no layout happen while views are created.

The laid-out result is cached on the device, keyed by the snapshot, the platform, the size, the color scheme, the scale, the app build and the OS, so later launches at the same size skip even the layout step. The cache holds only build-time data, nothing about the user. While the snapshot is on screen, a resize or a switch to dark mode lays it out again.

Kept honest

A snapshot is only useful if it is exactly what your app would have rendered. Octapus enforces that:

  • A snapshot baked from a different app.hbc is never adopted.
  • If Hermes's first commit differs from the snapshot, the snapshot is replaced by a normal render (adoption).
  • A snapshot written by an incompatible version of Octapus is refused, and the screen renders from JavaScript instead.

The byte layout is in the .ofrm reference.

On this page