.baked format
Byte layout of the first-screen snapshot (v4) and of the laid-out frame a device draws (v3).
.baked files come in two versions that share the magic number 0x4D52464F.
| Version | Written by | Contains |
|---|---|---|
| 4, the snapshot | bake 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 from the snapshot (the on-device cache stores v4 snapshots, Snapshots) |
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.
Where each fact lives
A snapshot does not name its language. What decides which file a screen opens, and what makes a file stale, is split between the file, the manifest and the on-device cache:
| Fact | Where | Checked |
|---|---|---|
| Format, style schema, style codec | Header 4, 68, 70 | The reader refuses any other value |
The app.hbc it was baked from | Header 16 (manifest.frame.hbcFnv repeats it) | Against the bytecode at open; another app.hbc means no first screen |
| Locale | The file name and manifest.frames: app.baked is the default locale's, app.<tag>.baked every other one's. Not in the header or the flags | The host opens frames[<the app locale>].file. A locale without a file mounts from JavaScript; no other language's file is opened |
| Writing direction | The baked computed styles (direction, unicode-bidi), cascaded at bake time with the locale's direction as the document's. Not in the header or the flags | The device sets the same document direction from the app locale before it lays the snapshot out |
| Cache identity | A device-cached file spells out the slot inputs in its name and stores their hash at header offset 72. A baked file has a reference viewport at offsets 24 and 28 and a zero slot key | iOS and Android check each cache hit against the expected slot (the on-device cache) |
A bundle without locales has one file, app.baked, and no frames.
v4: the snapshot
| Section | Contents |
|---|---|
| header | 80 B |
| batch | The first commit, encoded as UTF-8 JSON ({renderer, version, commands}). Its text is in the locale the file was baked for |
| 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 |
Every section starts on a 4-byte boundary (zero padding before it). The reader takes each section from its offset and length in the header and refuses a file whose section or host table ends past the end of the file.
Header (80 B)
| Off | Type | Field |
|---|---|---|
| 0 | u32 | magic 0x4D52464F |
| 4 | u16 | version (4) |
| 6 | u16 | flags: 1 = the page depends on the viewport (restyle everything on device); 2 = the bake probed system text sizes, so host flags 4 and 8 are valid (without it a device whose text size is not the default restyles everything). No bit names the locale or the direction |
| 8 | u32 | element count |
| 12 | u32 | elements restyled on every device (host flags 1 or 2) |
| 16 | u64 | Identity of the app.hbc it was baked from: FNV-1a 64 of the SHA-1 in the bytecode's last 20 bytes (hermesc writes it over the rest of the file), so the app checks it without reading app.hbc. A file that is not Hermes bytecode: FNV-1a 64 of all of it. Frames baked by earlier versions carry FNV-1a 64 of the whole file and are still accepted; a runtime from before the identity refuses a frame baked with it (the screen mounts from JS instead) |
| 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 5). Any other value is refused |
| 70 | u16 | style codec version (the binary computed-style encoding; currently 2, which adds appearance, nativeAppearance, gradients, transforms, transitions and animations). Any other value is refused. Fields added since keep the version and take new field ids (direction is 119, unicode-bidi 120); a reader that does not know a field id refuses the file |
| 72–79 | u64 | on-device cache slot key (0 in a baked app.baked or app.<tag>.baked): the hash of the slot the file was cached for. On iOS it is FNV-1a 64 of the bundle key (the app.hbc and app.css hashes, this build of the app, the OS version and the root's initial props), the viewport, scale, safe area, text size, the device's language and region with the app locale, and the cache name's format. The iOS and Android hosts write it through cache_frame and check it on a hit; a file whose key is not its slot's is not used |
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, 8 control, 9 SwiftUI host, 10 sheet (open dialog; its subtree is not drawn in the frame), 11 portal, 12 flow, 13 image, 14 native view (a placeholder box on the first screen). The table only grows; an index past it is refused |
| 13 | u8 | flags: 1 = restyle on device; 2 = its role depends on the viewport too, restyle its subtree; 4 and 8 = the same two, only on a device whose text size is not the default (valid with header flag 2) |
| 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 0x4D52464F |
| 4 | u16 | version (3) |
| 6 | u16 | header flags: 1 a scheme extension ("OSCH") follows the layout blocks (a second, dark paint table and per-row / per-run dark style ids), 2 the layout differs by scheme (a second layout block tagged dark); 0 in frames written before |
| 8 | u32 | nodeCount |
| 12 | u32 | styleCount |
| 16 | u32 | eventCount |
| 20 | u32 | strings byte size |
| 24 | u32 | layoutCount: 1, or 2 when header flag 2 is set |
| 28 | u32 | runs offset |
| 32 | u32 | nodes offset |
| 36 | u32 | styles offset |
| 40 | u32 | events offset |
| 44 | u32 | strings offset |
| 48 | u64 | hbcHash: identity of the HBC this snapshot was baked from (as in v4, offset 16) |
| 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. It then checks every row: a parent comes before its child, a drawn row's style, events and runs are inside their tables, a run's style is inside the style table, and every string reference is inside the pool.
A v3 frame has no revision field. The revision (currently 5: style row byte 92 is the paragraph direction) is part of the name a frame is cached under, so a reader never sees a frame written by another revision.
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 | 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]} | |
control | Control state JSON (below) | |
#text type row | Text content (used for structural matching) | |
bake-header type row | Header (@bake-native/octane/ui) props as JSON (title, subtitle, largeTitle, items …), so the navigation bar is set before JavaScript runs. Revision 2; empty in older frames, which then show no header until hydration | |
bake-tabbar type row | TabBar (@bake-native/octane/ui) props as JSON (items, selected, colors …), so the tab bar is set before JavaScript runs | |
| 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) |
| 8 | control | Form control drawn by its SwiftUI control (state JSON in aux) |
| 9 | swiftUI | SwiftUI host view |
Control state (aux of a control row)
A form control's kind and state, so the frame shows the right state before JavaScript runs. Keys are omitted when they hold their default.
| Key | Meaning |
|---|---|
k | Kind: 1 switch, 2 checkbox, 3 range, 4 select, 5 progress, 6 indeterminate progress, 7 meter, 8 date, 9 time, 10 datetime-local, 11 color |
c | true when checked |
v | DOM value (range: sanitized number; date YYYY-MM-DD; time HH:MM; color #rrggbb; select: the selected option's value) |
n / x / s | min / max / step attributes, as written |
o | Select options: [{"v": value, "l": label, "g": optgroup label, "d": true when disabled}] |
i | Selected option index |
d | true when disabled |
a | aria-label |
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 |
| 16 | passThrough | pointer-events: none |
| 32 | noSelect | user-select: none |
| 64 | selectAll | user-select: all |
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, 16 has accent color, 32 native control appearance (clear in frames written before it existed: their buttons were all CSS-painted), 64 font-synthesis-weight: none, 128 font-synthesis-style: none |
| 86 | u8 | -webkit-font-smoothing: 0 auto and subpixel-antialiased, 1 antialiased, 2 none |
| 87 | u8 | line breaking: low 4 bits word-break (0 normal, 1 break-all, 2 keep-all), high 4 bits overflow-wrap (0 normal, 1 break-word, 2 anywhere) |
| 88 | u32 | accent-color RGBA8 (valid only when flags has 16) |
| 92 | u8 | paragraph direction: 0 left to right, 1 right to left (direction: rtl; revision 5, 0 in rows written before) |
| 93–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; bit 31: the run is the ellipsis text-overflow / -webkit-line-clamp inserted (revision 4; mask it off before the style index) |
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 | scheme: 0 any, 1 dark (the dark block when header flag 2 is set) |
| 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. The children of a right-to-left scroll container are placed where they show at its start position (its right end).
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.