Skip to content

fix(studio): stop a group drag from jumping, and commit it in one request - #3134

Merged
miguel-heygen merged 2 commits into
stack/p5-mixed-colour-swatchfrom
stack/p7-drag-correctness
Aug 9, 2026
Merged

fix(studio): stop a group drag from jumping, and commit it in one request#3134
miguel-heygen merged 2 commits into
stack/p5-mixed-colour-swatchfrom
stack/p7-drag-correctness

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

Dragging a group no longer makes one member snap back to its starting position for a frame, and the whole group is saved in one request instead of one per member.

Why

Each member of a group was written separately, and every write patched the live GSAP tween in place and then seeked the player. A seek re-renders the whole timeline, not the tween that changed, so members still queued behind that write got repainted from their un-patched tweens — back to their pre-drag position, where they sat until their own write landed.

Separately, a three-element drag cost 3 writes and 9 parse reads, each write re-reading and re-serializing the whole composition.

How

The group commit defers the seek for every member but the last, so queued members keep the transform the gesture left on them and the group repaints once from the fully patched timeline. Mutations are queued and sent as one batch write; anything that re-reads the file flushes the queue first, so a member resolving a shared or stale tween never reads a composition missing writes it is about to build on. The parse endpoint shares an in-flight request per file.

Test plan

  • Measured in a real browser before and after: 9 reads + 3 writes became 2 reads + 1 write for a three-element drag
  • The jump reproduced in 3 of 3 runs before, 0 of 3 after; reverting the one-line change brings it back

Seventh of eight stacked PRs re-cutting #3077.

Dragging several elements at once and dropping them made one of them snap
back to where it started for a frame or two, then jump forward again.

Each member of the group is written separately, and every write patched the
live GSAP tween in place and then seeked the player. A seek re-renders the
WHOLE timeline, not the tween that changed, so the members still queued
behind that write got repainted from their un-patched tweens: back to their
pre-drag position, where they sat until their own write landed. Only members
whose tween actually renders at the playhead showed it, which is why a group
of three flashed one element and left the others still.

The group commit now defers the seek for every member but the last, so the
queued members keep the transform the gesture left on them and the whole
group repaints once, from the fully patched timeline.
Dragging N elements cost N writes and 9 reads for a three-element group: each
member fetched the composition's parse to preflight, fetched it again to
resolve its tween, then wrote the file on its own round trip. Every one of
those writes re-read, re-parsed and re-serialized the whole composition.

Three changes, same behaviour:

- The parse endpoint shares an in-flight request per file, so callers asking
  for the same composition at the same moment get one request. Only
  overlapping calls share — the entry is dropped as soon as it settles, so a
  read after a write still gets a fresh parse.
- The group preflight runs its members together instead of one at a time. A
  preflight writes nothing, so there is nothing to order.
- Members' mutations are queued and sent as one batch write. Anything that
  re-reads the file flushes the queue first, so a member resolving a shared or
  stale tween never reads a composition missing writes it is about to build
  on. The batch carries each member's runtime patch, and only the last one
  re-renders.

A three-element group drag now issues 2 reads and 1 write, down from 9 and 3.
@miguel-heygen
miguel-heygen force-pushed the stack/p7-drag-correctness branch from b71601a to f4825c5 Compare August 9, 2026 15:39
Base automatically changed from stack/p6-canvas-selection to stack/p5-mixed-colour-swatch August 9, 2026 15:40
@miguel-heygen
miguel-heygen merged commit f4825c5 into main Aug 9, 2026
32 of 33 checks passed
@miguel-heygen
miguel-heygen deleted the stack/p7-drag-correctness branch August 9, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant