BakeNative is under active development. APIs may change.
Skip to Content
BakeNative

.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.

VersionWritten byContains
4, the snapshotbake build --bakeThe first commit and baked styles, no geometry. Platform-neutral; this is what you ship
3, the laid-out frameThe deviceThe 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:

FactWhereChecked
Format, style schema, style codecHeader 4, 68, 70The reader refuses any other value
The app.hbc it was baked fromHeader 16 (manifest.frame.hbcFnv repeats it)Against the bytecode at open; another app.hbc means no first screen
LocaleThe 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 flagsThe host opens frames[<the app locale>].file. A locale without a file mounts from JavaScript; no other language's file is opened
Writing directionThe 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 flagsThe device sets the same document direction from the app locale before it lays the snapshot out
Cache identityA 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 keyiOS 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

SectionContents
header80 B
batchThe first commit, encoded as UTF-8 JSON ({renderer, version, commands}). Its text is in the locale the file was baked for
scopedJSON {moduleId: [[id, css], …]}: scoped <style> sheets registered before the first commit
light stylesBinary: 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 stylesSame, for dark mode. A device decodes only the scheme it shows
hosts16 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)

OffTypeField
0u32magic 0x4D52464F
4u16version (4)
6u16flags: 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
8u32element count
12u32elements restyled on every device (host flags 1 or 2)
16u64Identity 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 / 28f32reference viewport width / height (--viewport)
32 / 36u32batch: offset, length
40 / 44u32scoped: offset, length
48 / 52u32light styles: offset, length
56 / 60u32dark styles: offset, length
64u32hosts offset
68u16style schema version (role indices and style table layout; currently 5). Any other value is refused
70u16style 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–79u64on-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)

OffTypeField
0i32element id in the first commit
4u32light style index
8u32dark style index
12u8render 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
13u8flags: 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–15reserved

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] = v

Sections

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.

SectionSizeNotes
header64 B
nodesnodeCount × 56 BPre-order, includes #text rows
stylesstyleCount × 96 BDeduplicated paint styles
eventseventCount × 12 BRows that had listeners at bake time, and their event types
runsrun count × 12 BInline runs of text blocks
stringsbyte sizeUTF-8 pool
(padding)0–3 B4-byte alignment
layoutslayoutCount × (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)

OffTypeField
0u32magic 0x4D52464F
4u16version (3)
6u16header 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
8u32nodeCount
12u32styleCount
16u32eventCount
20u32strings byte size
24u32layoutCount: 1, or 2 when header flag 2 is set
28u32runs offset
32u32nodes offset
36u32styles offset
40u32events offset
44u32strings offset
48u64hbcHash: identity of the HBC this snapshot was baked from (as in v4, offset 16)
56u32number of drawn rows (rows that get a view)
60u32offset 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)

OffTypeField
0u8kind (table below)
1u8flags (table below)
2u16reserved
4u32parent row (0xFFFFFFFF = root)
8u32Core host ID at bake time (coreID)
12u32style row (0 for rows that are not drawn)
16 / 20u32text: offset, length
24 / 28u32aux: offset, length
32u32first event row
36u16event count
38u16reserved
40 / 44u32host type string (div, button, #text …): offset, length
48u32first run row
52u16run count
54u16reserved

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

Rowtextaux
buttonButton label
inputvalueplaceholder
svgSVG subtree JSON {"t": tag, "a": {attrs}, "c": [children]}
controlControl state JSON (below)
#text type rowText content (used for structural matching)
bake-header type rowHeader (@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 rowTabBar (@bake-native/octane/ui) props as JSON (items, selected, colors …), so the tab bar is set before JavaScript runs
OthersEmpty

An empty string is (0, 0). The actual content of a text block lives in its runs, not in text.

Kind

ValueNameView
0elementBox: background / border / children
1textBox + text runs
2buttonNative button (label in text)
3inputNative text field (text = value, aux = placeholder)
4rawText#text inside a text block (not drawn)
5svgInline SVG (subtree JSON in aux)
6styledButtonButton styled with CSS: box + label runs
7inlinePartInline element inside a text block (not drawn)
8controlForm control drawn by its SwiftUI control (state JSON in aux)
9swiftUISwiftUI 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.

KeyMeaning
kKind: 1 switch, 2 checkbox, 3 range, 4 select, 5 progress, 6 indeterminate progress, 7 meter, 8 date, 9 time, 10 datetime-local, 11 color
ctrue when checked
vDOM value (range: sanitized number; date YYYY-MM-DD; time HH:MM; color #rrggbb; select: the selected option's value)
n / x / smin / max / step attributes, as written
oSelect options: [{"v": value, "l": label, "g": optgroup label, "d": true when disabled}]
iSelected option index
dtrue when disabled
aaria-label

Flags

BitNameCondition
1hiddenNot rendered (display: none, empty text)
2notDrawnHas no view (inlinePart or a row that is not rendered)
4clipsoverflow-x or overflow-y is not visible
8clickableHas a click listener
16passThroughpointer-events: none
32noSelectuser-select: none
64selectAlluser-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.

OffTypeField
0u32background color RGBA8 (valid only when flags has 1)
4u32text color RGBA8
8 / 12 / 16 / 20u32border color top / right / bottom / left
24 / 28 / 32 / 36f32border width top / right / bottom / left
40 / 44 / 48 / 52f32corner radius top-left / top-right / bottom-right / bottom-left (px; 0 if not px)
56f32opacity
60f32font size
64f32letter spacing
68f32line height (px, when line-height kind is 1)
72 / 76u32font family string: offset, length (family list joined with U+001F)
80u16font weight
82u8line-height kind: 0 normal, 1 px (multipliers are baked to px as multiplier × font size)
83u8text-align: 0 start, 1 left, 2 center, 3 right, 4 end, 5 justify
84u8white-space: 0 normal, 1 nowrap, 2 pre, 3 pre-wrap, 4 pre-line, 5 break-spaces
85u8flags: 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
86u8-webkit-font-smoothing: 0 auto and subpixel-antialiased, 1 antialiased, 2 none
87u8line 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)
88u32accent-color RGBA8 (valid only when flags has 16)
92u8paragraph direction: 0 left to right, 1 right to left (direction: rtl; revision 5, 0 in rows written before)
93–95reserved

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)

OffTypeField
0u32node row
4 / 8u32event 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)

OffTypeField
0 / 4u32run text: offset, length
8u32style 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)

OffTypeField
0u16platform: 1 macOS, 2 iOS, 3 Android, 4 Web, 5 Windows
2u16scheme: 0 any, 1 dark (the dark block when header flag 2 is set)
4f32viewport width
8f32viewport height
12f32scale

Rect (32 B × nodeCount)

OffTypeField
0 / 4 / 8 / 12f32x, 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 / 28f32content 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.

On this page