.ofrm format
Byte layout of the first-screen snapshot (v4) and of the laid-out frame a device draws (v3).
.ofrm files come in two versions that share the magic number "OFRM":
| Version | Written by | Contains |
|---|---|---|
| 4, the snapshot | oct build --bake | The first commit and baked styles, no geometry. Platform-neutral; this is what you ship |
| 3, the laid-out frame | The device | The snapshot laid out for one platform and viewport, ready to draw in one pass. Built at launch and kept in the on-device layout cache |
All integers and f32 values are little-endian. A runtime refuses versions, style schemas and bytecode hashes it does not expect, and launches without the snapshot instead.
For what these files are for, see First-screen snapshot.
v4: the snapshot
| Section | Contents |
|---|---|
| header | 80 B |
| batch | The first commit, UTF-8 JSON as Octane's renderer emitted it ({renderer, version, commands}) |
| scoped | JSON {moduleId: [[id, css], …]}: scoped <style> sheets registered before the first commit |
| light styles | Binary: page styles (html, body, root), the canvas color, then every computed style. Each style stores only the fields that differ from the initial style |
| dark styles | Same, for dark mode. A device decodes only the scheme it shows |
| hosts | 16 B per element, in tree order |
Header (80 B)
| Off | Type | Field |
|---|---|---|
| 0 | u32 | magic "OFRM" |
| 4 | u16 | version (4) |
| 6 | u16 | flags: 1 = the page depends on the viewport (restyle everything on device) |
| 8 | u32 | element count |
| 12 | u32 | elements restyled on device |
| 16 | u64 | FNV-1a 64 of the app.hbc it was baked from |
| 24 / 28 | f32 | reference viewport width / height (--viewport) |
| 32 / 36 | u32 | batch: offset, length |
| 40 / 44 | u32 | scoped: offset, length |
| 48 / 52 | u32 | light styles: offset, length |
| 56 / 60 | u32 | dark styles: offset, length |
| 64 | u32 | hosts offset |
| 68 | u16 | style schema version (role indices and style table layout; currently 2) |
| 70 | u16 | style codec version (the binary computed-style encoding) |
| 72–79 | reserved |
Host row (16 B)
| Off | Type | Field |
|---|---|---|
| 0 | i32 | element id in the first commit |
| 4 | u32 | light style index |
| 8 | u32 | dark style index |
| 12 | u8 | render role: 0 box, 1 text, 2 button, 3 styled button, 4 input, 5 svg, 6 inline part, 7 none |
| 13 | u8 | flags: 1 = restyle on device; 2 = its role depends on the viewport too, restyle its subtree |
| 14–15 | reserved |
Baked styles leave out what only the cascade needs (roles are baked), and keep custom properties only where a restyled child inherits them.
v3: the laid-out frame
A v3 frame is what the device draws. Rows are in pre-order (parent < self), and each row points straight at its paint style, its text runs and its rectangle, so drawing is one forward pass with constant work per row:
for i in 0..<nodeCount:
n = node(i)
if n.flags & notDrawn: continue
v = makeView(n.kind) // element / button / input
v.paint = paint(styles[n.style], runs[n.runFirst ..< n.runFirst + n.runCount], insets(i))
v.frame = rect(i) // relative to parent view
v.hidden = n.flags & hidden
views[n.parent == 0xFFFFFFFF ? root : n.parent].addSubview(v)
views[i] = vSections
All integers and f32 values are little-endian. Sections follow each other in the order below with no gaps; the only padding is 4-byte alignment before the layout blocks.
| Section | Size | Notes |
|---|---|---|
| header | 64 B | |
| nodes | nodeCount × 56 B | Pre-order, includes #text rows |
| styles | styleCount × 96 B | Deduplicated paint styles |
| events | eventCount × 12 B | Rows that had listeners at bake time, and their event types |
| runs | run count × 12 B | Inline runs of text blocks |
| strings | byte size | UTF-8 pool |
| (padding) | 0–3 B | 4-byte alignment |
| layouts | layoutCount × (16 B + nodeCount × 32 B) | Per-platform layout blocks |
The run count is not in the header. It is computed as (stringsOffset − runsOffset) / 12.
Header (64 B)
| Off | Type | Field |
|---|---|---|
| 0 | u32 | magic "OFRM" (0x4D52464F) |
| 4 | u16 | version (3) |
| 6 | u16 | reserved (0) |
| 8 | u32 | nodeCount |
| 12 | u32 | styleCount |
| 16 | u32 | eventCount |
| 20 | u32 | strings byte size |
| 24 | u32 | layoutCount (always 1 with the current encoder) |
| 28 | u32 | runs offset |
| 32 | u32 | nodes offset |
| 36 | u32 | styles offset |
| 40 | u32 | events offset |
| 44 | u32 | strings offset |
| 48 | u64 | hbcHash: FNV-1a 64 of the HBC this snapshot was baked from |
| 56 | u32 | number of drawn rows (rows that get a view) |
| 60 | u32 | offset of the first layout block |
The reader checks the header length, magic, version (exactly 3), the strings section bounds, that nodes end before styles, and the bounds of each layout block.
Node row (56 B)
| Off | Type | Field |
|---|---|---|
| 0 | u8 | kind (table below) |
| 1 | u8 | flags (table below) |
| 2 | u16 | reserved |
| 4 | u32 | parent row (0xFFFFFFFF = root) |
| 8 | u32 | Octane core host id at bake time (coreID) |
| 12 | u32 | style row (0 for rows that are not drawn) |
| 16 / 20 | u32 | text: offset, length |
| 24 / 28 | u32 | aux: offset, length |
| 32 | u32 | first event row |
| 36 | u16 | event count |
| 38 | u16 | reserved |
| 40 / 44 | u32 | host type string (div, button, #text …): offset, length |
| 48 | u32 | first run row |
| 52 | u16 | run count |
| 54 | u16 | reserved |
coreID is not used for matching (matching is structural). It is for diagnostics, and for mapping early events that happened on the snapshot to runtime ids.
text / aux contents
| Row | text | aux |
|---|---|---|
button | Button label | |
input | value | placeholder |
svg | SVG subtree JSON {"t": tag, "a": {attrs}, "c": [children]} | |
#text type row | Text content (used for structural matching) | |
| Others | Empty |
An empty string is (0, 0). The actual content of a text block lives in its runs, not in text.
Kind
| Value | Name | View |
|---|---|---|
| 0 | element | Box: background / border / children |
| 1 | text | Box + text runs |
| 2 | button | Native button (label in text) |
| 3 | input | Native text field (text = value, aux = placeholder) |
| 4 | rawText | #text inside a text block (not drawn) |
| 5 | svg | Inline SVG (subtree JSON in aux) |
| 6 | styledButton | Button styled with CSS: box + label runs |
| 7 | inlinePart | Inline element inside a text block (not drawn) |
Flags
| Bit | Name | Condition |
|---|---|---|
| 1 | hidden | Not rendered (display: none, empty text) |
| 2 | notDrawn | Has no view (inlinePart or a row that is not rendered) |
| 4 | clips | overflow-x or overflow-y is not visible |
| 8 | clickable | Has a click listener |
Paint style row (96 B)
Everything the painter and text layout read from the computed style. Node styles and run styles share the same table, and rows with identical bytes are merged into one.
| Off | Type | Field |
|---|---|---|
| 0 | u32 | background color RGBA8 (valid only when flags has 1) |
| 4 | u32 | text color RGBA8 |
| 8 / 12 / 16 / 20 | u32 | border color top / right / bottom / left |
| 24 / 28 / 32 / 36 | f32 | border width top / right / bottom / left |
| 40 / 44 / 48 / 52 | f32 | corner radius top-left / top-right / bottom-right / bottom-left (px; 0 if not px) |
| 56 | f32 | opacity |
| 60 | f32 | font size |
| 64 | f32 | letter spacing |
| 68 | f32 | line height (px, when line-height kind is 1) |
| 72 / 76 | u32 | font family string: offset, length (family list joined with U+001F) |
| 80 | u16 | font weight |
| 82 | u8 | line-height kind: 0 normal, 1 px (multipliers are baked to px as multiplier × font size) |
| 83 | u8 | text-align: 0 start, 1 left, 2 center, 3 right, 4 end, 5 justify |
| 84 | u8 | white-space: 0 normal, 1 nowrap, 2 pre, 3 pre-wrap, 4 pre-line, 5 break-spaces |
| 85 | u8 | flags: 1 has background, 2 italic, 4 underline, 8 visibility hidden |
| 86–95 | reserved |
Colors are written as the value r << 24 | g << 16 | b << 8 | a in u32 little-endian (byte order in memory is a, b, g, r).
Event row (12 B)
| Off | Type | Field |
|---|---|---|
| 0 | u32 | node row |
| 4 / 8 | u32 | event type string (click, input …): offset, length |
Event types are sorted per node and written contiguously (the node's eventFirst, eventCount). This tells which controls are interactive even before JS exists; those events are buffered and replayed after adoption.
Run row (12 B)
| Off | Type | Field |
|---|---|---|
| 0 / 4 | u32 | run text: offset, length |
| 8 | u32 | style row |
Only drawn text and styledButton rows have runs. A run is an inline text fragment with CSS whitespace collapsing and text-transform applied; block-level properties come from the node's own style.
Strings
A UTF-8 byte pool. Each distinct string is stored once. References are always (offset, length), with the offset relative to the start of the strings section.
Layout blocks
Text measurement and control sizes differ by platform, so layout is kept in separate blocks. Blocks are placed contiguously starting at the first block offset (header 60).
Block header (16 B)
| Off | Type | Field |
|---|---|---|
| 0 | u16 | platform: 1 macOS, 2 iOS, 3 Android, 4 Web, 5 Windows |
| 2 | u16 | reserved |
| 4 | f32 | viewport width |
| 8 | f32 | viewport height |
| 12 | f32 | scale |
Rect (32 B × nodeCount)
| Off | Type | Field |
|---|---|---|
| 0 / 4 / 8 / 12 | f32 | x, y, w, h: frame relative to the parent view (top-level nodes relative to the document origin; buttons use the alignment rect) |
| 16 / 20 / 24 / 28 | f32 | content insets top, left, bottom, right (padding + border) |
Rows that are not drawn have a zero rect.
Block selection: the runner picks the block for its platform whose viewport width is closest (height is ignored). The format allows multiple blocks (platform × viewport class), but the current encoder writes only one.