First-screen snapshots on iOS and macOS

Agent-first.Write it for the web.Ship it native.

Octapus runs a plain Octane .tsrx app on Hermes with real UIKit and AppKit views. A first-screen snapshot baked at build time is on screen in under 3 ms, before any JavaScript runs. Your agent writes the app; one build command tells it what broke.

oct build --target web,ios,mac --bake

Safari, DOM
WebSafari, DOM
UIKit, drawn by Octapus
NativeUIKit, drawn by Octapus
2.9mssnapshot on screen, no JS
0viewscreated when Hermes adopts
1filesame App.tsrx on both

iOS Simulator captures of examples/app. The native capture keeps its launch overlay: created on adopt 0 · cache: hit.

Launch, replayed

The first screen is already there

Two real launches of the same app, slowed down 20×. Without a snapshot the screen stays blank until Hermes has built the whole tree. With one, the frame is up in under 3 ms and Hermes adopts the views that are already on screen.

0.0ms after launch

Without a snapshot

Blank until Hermes has run the app and created every view.

  • 251 ms interactive

Not launched yet

With the first-screen snapshot

The snapshot (.ofrm) is drawn before any JS. Hermes then adopts those views.

  • 2.9 ms on screen
  • 57 ms interactive

Not launched yet

Timings from the example app's LaunchMetrics log in the iOS brownfield host (iOS Simulator). The snapshot launch is a frame-cache hit: read 0.09 ms, draw 2.8 ms, adopt 4.8 ms.

Live demo

Click it. It's the real app.

The frame below is examples/app built with oct build --target web: a small gallery of demos. Its Starter tab is the official Octane starter, the screen in the native captures above.

Loading the example app…

Counter.tsrx (simplified)
import { useState } from 'octane';

export function Counter() @{
  const [count, setCount] = useState(0);

  <button onClick={() => setCount(count + 1)}>
    {'Count: ' + count}
  </button>
}
Same file, every target:
  • web → DOM
  • ios → UIKit
  • mac → AppKit

Pipeline

One source, one build

Web ships as DOM. Native ships as Hermes bytecode plus a first-screen snapshot. At launch the snapshot shows first and Hermes hydrates it.

Features

Same screen everywhere, no JS on the first screen

Same look on web, macOS and iOS

One shared core computes the CSS cascade, web layout, CoreText text and painting. AppKit and UIKit only host the views.

A first screen without JS

A first-screen snapshot (.ofrm) baked at build time is drawn in one forward pass, O(1) per row. Hermes comes after.

Brownfield-first iOS

Drop OctapusView into an existing UIKit or SwiftUI app. The public modules expose C headers only, so C++ interop stays off.

One CLI for every target

oct build builds web, ios, android, mac and windows with Vite + Octane. Branch per target with import.meta.env.OCT_TARGET.

Usage

Build it, drop in one view

Terminal
$ pnpm install && pnpm hermes
$ pnpm app
# = oct build --target web,ios,mac --bake

# or run it directly
$ oct build --target web,ios,mac --bake \
    --viewport 640x480
ContentView.swift
import OctapusAppKit
import SwiftUI

struct ContentView: View {
  var body: some View {
    // dist/mac: app.hbc + app.ofrm + app.css
    OctapusView(bundle: OctapusBundle(directory: url))
  }
}

Measured on macOS

Numbers from the official Octane starter

Native layout within 2 px of the web layout
22/22 nodes
To draw the 22 first-screen views without JS
~1.1 ms
Created during adoption (35 rows matched)
0 views
First screen to interactive (dev tool, debug build)
~150 ms

Measured on macOS with the official Octane starter app (examples/app). Time to interactive is from a debug build in the dev tool.