Skip to content
Blog

A frame rate is a grid, never a time — why nesting just works

AtomCut has no document-wide frame rate. Every comp carries its own, and a rate only quantizes — which is why nested compositions compose for free.

SShayanBuilding AtomCut
A fine, precise grid of evenly spaced thin metal pins on a graphite plate, seen at an angle, crossed by a line of orange and pink light.

AtomCut has no document-wide frame rate. Every comp, every artboard, every nested composition, every flipbook, carries its own fps, and there is no shared default they fall back to. That sounds like it should cause chaos: what happens when a 12fps flipbook plays inside a 60fps scene? The answer is nothing happens, in the good sense. The child holds each drawing for 83.33ms regardless of what's watching it, the parent samples it every 16.67ms and sees the same drawing about five times, and neither side has to ask the other anything. That property, nesting composes for free, is a direct consequence of one design decision: a frame rate is a grid, never a time.

The question every timeline tool eventually asks

If you've built anything with nested compositions (comps inside comps, symbols inside symbols, sequences inside sequences) you've hit this question: when the child's timeline runs at a different rate than the parent's, whose rate wins? The obvious design is a document-level rate that comps inherit, with the option to override it per-comp. It reads clean in a schema diagram. It is also where the bugs live, because the moment a rate is asked to do double duty — describing when something happens and how densely you can look at it — those two jobs eventually disagree.

That's exactly what happened here before v48. There was a document-global rate plus per-frame overrides, and roughly half the app read one and half read the other: the ruler, the curve and dope-sheet grids, the frame-step shortcuts and marker snapping read the document's rate, while the exporter and the flipbook read the frame's own. A 12fps drawing sheet still stepped on a 30fps grid in half the UI, because the two halves of the app were quietly disagreeing about which number was authoritative.

What "a grid, never a time" actually means

Every time value in the document (a clip's start, its duration, a keyframe's position, a marker, a caption cue) is milliseconds, full stop, and nothing in the frame-rate system ever touches one of those values to convert it. A rate answers a completely different question: where are the legible instants in this comp? It's what the ruler ticks on, what the arrow keys step by, what the curve and dope-sheet grids draw, what snapping magnetizes to, and what the exporter iterates on. That's the whole job. packages/core/src/timeline/fps.ts states it as the module's one-line thesis:

ts
// packages/core/src/timeline/fps.ts
/**
 * Frame rate — the one brain (v48).
 *
 * ## The model, in one line
 *
 * **Time is milliseconds. A frame rate is a GRID, never a time.**
 */

Because a rate is only ever a lens you look at millisecond-time through, it can live on the thing being looked at — the frame — with nothing above it to disagree with. There's no document rate to inherit, override, or fall out of sync with:

ts
// packages/core/src/timeline/fps.ts
/** This frame's rate. The one reader — never touch `frame.fps` directly. */
export function frameFps(_doc: AtomCutDocument, frame: Frame): number {
  return normalizeFps(frame.fps);
}

And there's exactly one place that's allowed to change it:

ts
// packages/core/src/timeline/ops.ts
export function setFrameFps(doc: AtomCutDocument, frameId: string, nextFps: number): void {
  const frame = doc.frames.find((f) => f.id === frameId);
  if (!frame) return;
  const from = frameFps(doc, frame);
  const to = normalizeFps(nextFps);
  if (from === to) return;
  frame.fps = to;
  if (frame.role === "flipbook") retimeFlipbookCells(doc, frameId, from, to);
}

Every other reader — the ruler, the exporter, the shortcuts, the snapping — calls frameFps or compFps and gets the same answer, because there is only one field to ask.

Why nesting composes for free

This is the part that actually pays off. Because a rate only quantizes and never resamples, a parent comp doesn't need to know or care what rate its children run at. It asks the child "what do you look like at this millisecond," and the child answers from its own millisecond-addressed content — which happens to be quantized to its own grid. ARCHITECTURE.md puts the mechanism plainly:

Because a rate only ever quantizes — it is what the ruler ticks on, what arrow keys step by, what snapping magnetises to and what the exporter iterates on — nesting composes for free and no rate change may move a keyframe. A 12fps flipbook inside a 60fps comp holds each cell for 83.33ms regardless; the parent samples it every 16.67ms and sees the same cell five times. Nothing inherits, negotiates or resamples across a comp boundary, so nothing can drift.

"Nothing can drift" is the operative phrase. If a rate change could move a keyframe, or if nesting triggered a resample, then round-tripping through a few levels of nested comps at different rates would slowly detune your timing, the way repeatedly re-encoding a video slowly degrades it. Here it can't happen, because the grid is a read-only lens and the underlying millisecond values never move when you change what rate you're viewing them through.

The render clock that makes this concrete is quantizeMsToFrame — floor, not round, because a frame is a span you're inside of, not a point you're closest to:

ts
// packages/core/src/timeline/fps.ts
export function quantizeMsToFrame(ms: number, fps: number): number {
  if (ms <= 0) return 0;
  return frameIndexToMs(msToFrameIndex(ms, fps), fps);
}

Playback, scrubbing, export and thumbnails all call this same function against whichever comp they're drawing, so they can never disagree about which frame a given moment belongs to — which is exactly the disagreement the old document-global rate used to produce.

The one deliberate exception

There's exactly one place where a rate change does more than change what you're looking through: the flipbook. A flipbook cell isn't a window onto continuous content the way a video clip is — it is a drawing, one per held frame. When you change a flipbook's fps, there's no continuous content underneath to resample; there are individual sheets of paper, and changing the rate is asking "hold each drawing for a different number of frames." That's why setFrameFps special-cases it:

ts
frame.fps = to;
if (frame.role === "flipbook") retimeFlipbookCells(doc, frameId, from, to);

This is an explicit authoring operation the user asked for, not a side effect of where a rate happens to be stored. Getting the boundary between "the grid changed" and "the content should re-cut" wrong was its own multi-week debugging story — notes/ADR-flipbook-time-and-placement.md records five separate flipbook bugs that all looked like drawing bugs and were actually two clocks disagreeing about where a frame starts, down to fractions of a millisecond, because index × step and the stored, rounded value for the same instant aren't bit-for-bit identical unless you're careful to derive both from the same function.

The whole module (presets, grid math, the one writer) is packages/core/src/timeline/fps.ts in the repo, and the migration that removed the document-global rate is in packages/core/src/io/index.ts. Take a look.