Glint specification /drafts/00/clips/

Glint clips

Status
NORMATIVE for clip format version 1
Draft
Draft 00, 2026-11-26
Markdown
/drafts/00/clips.md
Contents

Status: NORMATIVE for clip format version 1, which holds the messages of Glint format version 8 (the specification).

A clip is the paint of a document over time, kept in a file or in bytes in memory. It holds the Glint messages that a server sends one client, and the presentation time of each frame. A player draws a clip without a network and without the document, as a client draws a stream.

A clip is Glint: its frames are Keyframe and Delta messages, and its resources are the resource messages of the stream format. The clip adds a container: a header, timed records, keyframe points, segments, hotspots and an index.

A clip is the one file format of Glint. Its file name ends in .glint. A clip of one frame, a Keyframe at time 0, is a still: the paint of the document at one moment.

All integers are little-endian. A varint is an unsigned LEB128 integer of at most five bytes. An f32 is an IEEE 754 binary32 value. A time is a u64 count of microseconds. Offsets are decimal bytes from the start of the clip or of the body.

Records

A clip is a sequence of records. Each record is:

FieldSize
kindu8
body lengthvarint
bodybody length bytes
KindRecordBody
1Headerthe fields of “Header” (45 bytes)
2Resourceone Glint resource message: Configuration (2), Font (3), Image (4), Image release (5), Path (6), Glyphs (13), Color glyph (14) or Variation (17)
3Framepresentation time (u64), then one Glint Keyframe (7) or Delta (8) message
4Indexthe fields of “Index”
5Segmentthe segment name: 1 to 255 bytes of UTF-8 text (“Segments”)
6Hotspotsthe fields of “Hotspots”

A Glint message in a Resource or Frame record is complete: its kind, its body length and its body (“Messages” in the specification). It fills the rest of the record body exactly.

A reader that meets a record kind that this table does not have fails with error 25, which names the kind and the offset of the record. A reader never skips a record.

The first record of a clip is its Header, and a clip has one Header. Its body:

OffsetFieldTypeValue
0signature8 bytes89 47 4C 43 0D 0A 1A 0A
8clip format versionu321
12Glint format versionu328: the format version of the messages
16codecu8the codec bit of every compressed part in the clip (“Codecs” in the specification): 1 zstd, 2 deflate-raw, 4 none
17viewport widthf32CSS pixels
21viewport heightf32CSS pixels
25device scalef32device pixels per CSS pixel
29durationu64the presentation time of the last frame record; 0 in a clip that its writer did not finish
37index offsetu64the offset of the Index record; 0 in a clip that its writer did not finish

The viewport and the device scale are those of the first Configuration of the clip: its visible rectangle width and height, and its device scale. A player draws the clip at any size and device scale; the header gives the size at which the clip was recorded.

A Header with another signature, another length, a clip format version other than 1, a Glint format version other than 8 or a codec that is not one codec bit is error 24, which names the offset of the field and its value.

Versions

The clip format is not yet declared stable. Until it is, a reader reads only the current version: clip format version 1, which holds the messages of Glint format version 8.

  • A clip of another clip format version, or with messages of another Glint format version, fails with error 24. The error names the version that the reader read (its value) and the one version that the reader reads: 1 for the clip format version, at clip offset 10, and 8 for the Glint format version, at clip offset 14.
  • A reader does not read an older version, and a writer writes only the current version.
  • A change to the format before it is declared stable changes the current version. Clips of the earlier version must be written again.

Frames

A Frame record holds one Glint frame and the time at which a player presents it: its presentation time, in microseconds from the start of the clip.

  • The first Frame record has presentation time 0 and holds a Keyframe of sequence 1.
  • Each later Frame record has a presentation time above that of the Frame record before it, and holds the frame whose sequence follows: the sequence of the frame before it plus 1.
  • The base sequence of a Delta is the sequence of the Frame record before it. A clip therefore holds every frame that a Delta can name.
  • The command revision of each frame is its sequence, as in a stream.

A frame that breaks one of these rules is error 27 (a presentation time) or error 28 (a sequence, a base or a command revision).

The frame shows from its presentation time until the presentation time of the next Frame record. The last frame shows from its presentation time on; its presentation time is the duration of the clip.

Resources

A Resource record holds one resource message. The resource messages of a clip are those that the server sent its one client, in the order that the server sent them. They follow the rules of a connection (“Resources” in the specification and the resources): a resource message precedes the first frame record that reads its resource, at its first use; font n is the n-th Font message of the clip; a Color glyph message installs the next cache slot of the clip.

The resource count of each frame (the last field of a Keyframe or Delta header) is the number of Resource records before its Frame record. A frame whose count differs is error 30.

A clip holds no Hello, Role, Document state or client message. The codec of the server’s Hello is the codec of the header.

Configuration at a keyframe

The Configuration of a frame changes only at a keyframe: a Resource record that holds a Configuration message is followed by a Frame record that holds a Keyframe, with only Resource records between them. The first Frame record has a Configuration before it. A Configuration before a Delta is error 26.

Keyframe points

Each Frame record that holds a Keyframe is a keyframe point. A player starts at a keyframe point when it seeks.

The list of a keyframe point is the Resource records before it that define the connection there, in clip order. Every Resource record before the point is in the list, except a record whose resource a later record before the point replaces:

ResourceReplaced by
Configurationthe next Configuration
Image of an entry kind and an image indexthe next Image or Image release of the same entry kind and index
Path of path kind 0 or 2 and a path indexthe next Path of the same path kind and index
Image releaseitself: it leaves the list with the Image that it releases

A Font, Glyphs, Color glyph or Variation message, and a Path of path kind 1, stays in the list: the connection numbers fonts, variation keys, color glyph slots and color glyph layer paths by the order of these messages, and a font file holds the glyph data of every Glyphs message of its font.

A client that receives the list’s messages, then the records from the point on, holds every resource that the frames from the point on read, with the numbers that the server gave them. The list is shorter than the Resource records before the point by the replaced records: a reader that starts at a point gives each frame from the point on with its resource count less that number, which is then the number of resource messages that the client received.

Keyframe interval

A writer has a keyframe interval in microseconds. After a frame at a presentation time that is the interval or more after the last keyframe point, the writer asks the server for a Keyframe as the next frame, which becomes a keyframe point. A frame that changes the Configuration is a Keyframe (“Configuration at a keyframe”), and so a keyframe point. The server also writes a Keyframe when a Delta is not smaller, which is a keyframe point too.

Index

The Index record is the last record of a finished clip, at the offset that the header names. Its body:

FieldType
point countu32
for each keyframe point, in clip order: the offset of its Frame record, its presentation timeu64, u64
the length of its list, then the number of each Resource record of the list (the n-th Resource record of the clip is number n)u32, u32 each
Resource record countu32
for each Resource record, in clip order: its offsetu64
segment countu32
for each Segment record, in clip order: its offset, the number of its keyframe point (the first point is number 0)u64, u32
Hotspots record countu32
for each Hotspots record, in clip order: its offset, the presentation time of its Frame recordu64, u64

An Index whose fields differ from the records of the clip, a header whose index offset names no Index record before the end of the clip, and a header of a clip with an index whose duration is not the time of the last frame are error 31.

A clip without an Index (a writer that did not finish, or a clip that ends before its index offset) plays from its start. It cannot seek: a seek is error 32, which names the clip length and the index offset of the header.

Seeking

A seek to presentation time T starts at the last keyframe point at or before T, or at the first point for an earlier time. The reader gives:

  1. A Hello of the clip’s Glint format version, with the codec of the header.
  2. The message of each Resource record of the point’s list.
  3. The message of each record from the point’s Frame record on, each frame with its resource count less the replaced records before the point.

A player draws the frame at T after it gives the client the frames up to the last frame at or before T. A seek uses the index: a reader that has read only the header and the Index finds the point and the offsets of the records that the list names.

Playing

A player draws a clip from its bytes, without a network and without the document. It keeps the current presentation time and the next record, and the host gives it the time of each display frame:

  • While the clip plays, the presentation time is the host time less the host time at which the clip’s time 0 was. At the end of a segment, the segment-end mode of the player tells what follows (“Segment ends”). At the duration the clip stops and shows its last frame, except in mode loop.
  • Play at or after the last frame of the segment of the presentation time starts again at the start of that segment. In mode continue and in a clip without segments, the segment is the clip: play at the end of the clip starts again at time 0.
  • Pause keeps the presentation time; the frame at that time stays.
  • A seek to time T (0 to the duration) starts at the keyframe point at or before T (“Seeking”), and the presentation time becomes T.
  • A seek to a keyframe point goes to the last point before the presentation time (the first point when no point is before it) or to the first point after it.
  • At each display frame, the messages that are due go to the client: each message up to the last frame at or before the presentation time. The client draws the newest frame. A Hello starts a new client endpoint.

The player draws the frame of a presentation time with the pixels of a client that receives every message of the clip from its start up to that frame.

A player that plays clip after clip keeps one runtime. The start of a second clip in a running runtime, open to first frame drawn (a dashboard clip of 640 × 400 at scale 2), should take at most 20 ms in Chrome, 40 ms in Deno and 60 ms in Firefox.

Segments

A segment is a named range of a clip. A Segment record names the segment that starts at the next Frame record. That Frame record holds a Keyframe, so a segment starts at a keyframe point. A segment ends at the start of the next segment, or at the end of the clip.

  • The name of a segment has 1 to 255 bytes and holds no @ (byte 0x40). Two segments of a clip have different names. A reader compares names byte for byte.
  • The start time of a segment is the presentation time of its Frame record. The length of a segment is the start time of the next segment less its start time; for the last segment, the duration less its start time.
  • The frames before the first Segment record belong to no segment. A clip without Segment records is one segment without a name.

A Segment record whose name breaks a rule of this list is error 33. A Segment record before a Frame record that holds a Delta is error 26.

Segment ends

A player has a segment-end mode. The mode tells what the player does when the clip plays to the end of a segment:

ModeAt the end of a segment
stopThe player pauses on the last frame of the segment. This is the default mode.
loopThe player plays the segment again from its start.
continueThe player plays on into the next segment.

The last frame of a segment is the last Frame record before the start of the next segment. The last frame of the last segment is the last frame of the clip. The segment that ends is the segment of the current presentation time: after a seek or a press, the segment of the new time.

  • In mode stop, the player pauses when the presentation time reaches the last frame of the segment. The presentation time becomes the time of that frame. Play then starts again at the start of the segment.
  • In mode loop, when the presentation time reaches the end of the segment, the presentation time goes back by the length of the segment until it is in the segment, and the player seeks there (“Seeking”). When the display frame before the end shows a frame before the last frame, the player first shows the last frame for one display frame. A last segment that holds one frame does not loop: the player pauses on that frame.
  • In mode continue, the player plays on to the end of the clip, as for a clip without segments.
  • At the end of the clip, the player pauses on the last frame in modes stop and continue. In mode loop, the last segment plays again.
  • The frames before the first segment belong to no segment. From them, the player plays on into the first segment, and the mode applies at the end of the first segment.
  • A clip without Segment records is one segment: in mode loop the clip plays again from time 0.
  • A clip without an Index cannot seek (“Index”). The player plays it in mode continue.

Writing segments

The host of a writer names a segment before the frame that starts it. The writer then asks the server for a Keyframe as the next frame, as it does at the keyframe interval (“Keyframe interval”). The writer writes the Segment record before the records of that frame.

Hotspots

A hotspot is a rectangle of the viewport in a frame. A press in it starts a segment of the clip at a time in that segment. A Hotspots record lists the hotspots of the next Frame record and of each later frame, up to the next Hotspots record. The frames before the first Hotspots record have no hotspots, and a Hotspots record with no hotspot removes them.

The body of a Hotspots record:

FieldType
hotspot countu32
for each hotspot: x, y, width, heightf32 each, CSS pixels of the viewport
the time in the target segmentu64, microseconds
the target segment namea varint byte length of 1 to 255, then the name

The fields of each hotspot follow the fields of the hotspot before it, and the last hotspot fills the body exactly. Each value of a rectangle is finite, and the width and the height are above 0. The time is below 2^53. A Hotspots record that breaks one of these rules is error 34.

The target segment of each hotspot is a segment of the clip, and the time is at most the length of that segment. A hotspot that breaks this rule is error 35.

Hotspots of a recorded document

A writer that records a document takes the hotspots of each frame from the layout of that frame:

  1. The writer finds each element of the document tree that has the attribute data-glint-hotspot, in tree order.
  2. The attribute value is the target segment name, then optionally @ and the time in that segment. The name is the text before the first @.
  3. The time is a CSS time without a sign or an exponent, of 12 digits or less: for example 250ms or 1.5s. The time is 0 when the value has no @.
  4. The rectangle of the hotspot is the border box of the element, as getBoundingClientRect() gives it. An element without a box, or with a width or a height of 0, gives no hotspot.

A value whose name has no byte or more than 255 bytes, or whose time is not such a CSS time or is not a whole number of microseconds, is error 34. The writer writes a Hotspots record before a frame when the hotspots of that frame differ from those of the frame before it.

A press

A player takes a press at a point (x, y) in CSS pixels of the viewport, at its current presentation time. It finds the hotspot of the press:

  1. The hotspots of the time are those of the last Hotspots record whose Frame record is at or before the time.
  2. A hotspot contains the point when x is at least its x and less than its x plus its width, and y is at least its y and less than its y plus its height.
  3. When more than one hotspot contains the point, the last of them in the record is the hotspot of the press. A recorded document lists its elements in tree order, so an element after another element wins.

When a hotspot contains the point, the player seeks to the start time of the target segment plus the time of the hotspot (“Seeking”), and plays from there. When that time is the end of the target segment, the player seeks to the last frame of the segment. A playing clip plays on, and a paused clip starts to play. At the end of the target segment, the player does what its segment-end mode tells (“Segment ends”). When no hotspot contains the point, the press does nothing.

Order

The records of a clip are in this order:

  1. The Header.
  2. The records of each frame, in time order:
    1. A Segment record, when a segment starts at the frame.
    2. A Hotspots record, when the hotspots change at the frame.
    3. The Resource records of the resource messages of the frame.
    4. The Frame record.
  3. The Index, in a finished clip.

The order of the records, the Header and the Index in their places and the resource kinds in Resource records are rules of error 26. A frame has at most one Segment record and one Hotspots record. A clip holds at least one Frame record; a clip without one is error 26 with value 0. The records end with a Frame record: other records after the last frame are error 26.

Reading a clip

A reader gives a client endpoint the messages of a connection, as a server gives them:

  1. A Hello of the clip’s Glint format version, with the codec of the header.
  2. The message of each Resource and Frame record, in the order of the records. A Segment or Hotspots record holds no message.

A client that reads these messages draws each frame as it draws the frames of a stream. It acknowledges no frame to the clip.

Writing a clip

A writer is the one client of a Glint server. It offers one codec in its Hello, and records each message that the server sends:

  • A resource message waits for the next frame.
  • A frame, with the resource messages before it, becomes Resource records and a Frame record with the presentation time that the writer’s host gives the frame. A Segment record and a Hotspots record precede them when the frame starts a segment or changes the hotspots (“Segments”, “Hotspots”). A render that changes nothing sends no frame and adds no record: the frame before it shows on.
  • A Role or Document state message is not part of the clip.

The writer acknowledges each frame before the server renders the next one, so that the base of each Delta is the frame before it and the server sends every frame.

A clip is canonical: its bytes are a function of its frames and their presentation times alone, not of the frames and fonts that the server prepared before. Every endpoint numbers the fonts and the variation keys of its connection by first use (“Font numbers” and “Variation key” in the resources), and every producer numbers the scroll entries, the gradient stops and the scrollbar groups of each frame by first use and writes the rows of stream 5 in one total order (the frame streams). The command revision of each frame is its sequence. Two writers that record the same frames at the same presentation times write equal bytes.

Errors

The clip errors continue the codes of “Errors” in the specification. The offset is a byte offset in the clip unless the table names another.

CodeNameOffsetValue
24Not a clip of version 1 with messages of format 8the offset of the header field in the clipthe field: a signature byte, the body length, a version or the codec. At a version field (offset 10 or 14), the reader also names the one version that it reads (“Versions”)
25Unknown record kindthe offset of the recordthe kind
26A record out of the order of a clipthe offset of the record; for a writer, the length of the clip written so farthe record kind, or the message kind for a message that a record cannot hold; 0 for a clip without a frame or a frame without a server message; 5 for a Segment record before a Delta, or a second segment before one frame
27A presentation time that is not after the time of the frame before it, or a first time that is not 0; for a writer, a time or a keyframe interval that is not a whole number of microsecondsthe offset of the Frame recordthe presentation time in milliseconds
28A sequence that does not follow the frame before it, a Delta base that is not the frame before it, or a command revision that is not the sequencethe offset of the Frame recordthe sequence, the base or the command revision
29A record that ends after the clip, or a varint of more than five bytesthe offset of the recordthe body length
30A frame whose resource count is not the number of Resource records before itthe offset of the Frame recordthe frame’s resource count
31An Index that differs from the records, a header index offset that names no Index record, or a header duration that is not the time of the last frame of a clip with an indexthe offset of the first differing byte of the Index, or of the header fieldthe byte, or the header field (the duration in milliseconds)
32A seek in a clip without an Indexthe index offset of the headerthe clip length
33A segment name that is empty, longer than 255 bytes or holds @, or that is the name of an earlier segmentthe offset of the Segment record; for a writer, the length of the clip written so farthe name length, or the number of the earlier segment of that name (the first segment is number 0)
34A Hotspots record whose fields do not fill its body exactly, or a hotspot with a value that is not finite, a width or a height that is not above 0, a time of 2^53 or more, or a target name of no byte or more than 255 bytes; for a writer, a data-glint-hotspot value without such a name and a CSS timethe offset of the Hotspots record; for a writer, the length of the clip written so farthe number of the hotspot in the record (the first is number 0), or the hotspot count for bytes after the last hotspot
35A hotspot whose target is not a segment of the clip, or whose time is after the length of its target segmentthe offset of the Hotspots recordthe number of the hotspot in the record