Skip to content

Draw ahead of the pen: an experimental setting for ink delay on old or high-latency devices (#287) - #419

Merged
Joost-8 merged 2 commits into
mainfrom
claude/issue-287-predicted-ink-3b7ac8
Dec 4, 2026
Merged

Joost-8 merged 2 commits into
mainfrom
claude/issue-287-predicted-ink-3b7ac8

Conversation

@Joost-8

@Joost-8 Joost-8 commented Dec 4, 2026 •

Copy link
Copy Markdown
Owner

Not verified on device: @OskarRabenda, please test on Android with the overlay on, setting off then on, and look for hooks at turns.

What changed and why

An experimental setting, Settings › Troubleshooting › Draw ahead of the pen ("Experimental, for old or high-latency devices."), off by default. With it on, the pen's predicted samples (PointerEvent.getPredictedEvents()) draw a short tail ahead of the stroke, to test whether it hides some of the ink delay on Android (#287: FineNotes' own work is ~20 ms; the rest is the WebView's compositor, which no page can reach).

The tail is at most 6 screen px and 12 ms ahead, stops where a guess turns more than 25° from the pen's heading, and lives only on the wet layer's copy of the open run: redrawn every frame, never in the stroke or the tracer, gone at the lift. The limits are constants at the top of src/ink/predicted-tail.ts. Where the browser has no getPredictedEvents, nothing happens. With the setting off, the controller hands nothing over and the wet layer draws exactly as before (the iPad included; 1.0.2's reasons for not drawing WebKit's predictions still stand). Refs #287.

Proof

  • Pure module src/ink/predicted-tail.ts (in coverage), tests tests/ink/predicted-tail.test.ts: cap at the length limit at any zoom, time horizon, a sharp turn ends the tail, no heading draws nothing, the overlay figure.
  • tests/input/pointer-controller.test.ts "hands over predicted samples apart from the stroke, only with Draw ahead of the pen on": off sends nothing; on, guesses before the move; missing API and mouse send nothing.
  • tests/view/ink-surface.test.ts "draws the pen's guesses only as a short tail on the frame, never in the stroke": the frame's run gains the tail, the builder's points do not, cleared draws as before.
  • The overlay's latency line gains pred=<share of frames with a tail>% <mean tail>px +<how far ahead the guesses reach>ms, only once guesses arrive, so a tester can see whether anything is drawn.
  • npm run gates: all 11 steps pass. UI check: every scene renders; its 7 finding groups are the ones main has had for 8 nights, none in settings. Gallery shots of the new row, light and dark: review page https://claude.ai/artifact/DCtcC4bnNPwLMeBG4eJFbx (private to Joost).
  • Reviewer agent: found a stale tail reaching Zoom box strokes (fixed: guesses are forgotten at every press start), and that the overlay could not show whether a tail was drawn (fixed: pred=).
  • ink-surface.ts +12 and ink-view.ts +1 lines of wiring; their caps in file-size.json are raised by that.

Test on the device

On the Android tablet (Galaxy Tab or Oskar's), in a notebook:

  1. Settings › Troubleshooting: turn on Input debug overlay, leave Draw ahead of the pen off. Write a few lines; note the lat ink …/frame … line (no pred= appears).
  2. Turn on Draw ahead of the pen; write the same lines. The line now ends in pred=…% …px +…ms: the share should be well above 0 and the px a few. Say whether the ink feels closer to the pen (a slow-motion video, off vs on, says it best).
  3. Write quick zigzags, loops and sharp turns: look for hooks or flicks at the ink's end that vanish a frame later, and whether the ink's end pulls back when the pen stops.

Not verified

  • Nothing on a device: no Android emulator by decision; Oskar tests from this PR. How far ahead Chromium predicts on the Tab S8 Ultra is unknown (the +ms figure will say); if it is past 12 ms, nothing is drawn and PREDICT_MAX_MS needs raising.
  • Not in the vault build yet: vault.mjs add 419 was refused because another session holds the vault branch in its worktree.
  • No redraw measurement (the 2026-09-30 removed/added ratio) for Chromium's guesses; 6 px is above the cuts measured on WebKit (3 px: 6 % redrawn). Tune PREDICT_MAX_PX from Oskar's results.
  • The lat figures time the newest real sample, so they will not move with the tail; the feel is the measure.
  • The row shows on every platform (off), as the brief asked; iPad users are not steered to it.
  • Translations: the drift tool says locales follow the translation routine; the 42 were added here because the task asked for them. Some run past 60 characters, as other rows do.
  • research/engines/INK-ENGINE.md (private) still says predictions are never drawn; a worktree session cannot edit it. The lines to add are in the session notes.

🤖 Generated with Claude Code

Joost-8 and others added 2 commits December 4, 2026 03:55
#287)

Off by default. With it on, a pen's predicted samples (getPredictedEvents)
draw a short tail ahead of the stroke on the wet layer: at most 6 screen px
and 12 ms ahead, cut where a guess turns more than 25 degrees from the pen's
heading. It is redrawn every frame, never stored in the stroke or the
tracer, and gone at the lift. Where the browser has no predictions, nothing
happens. With the setting off, the controller hands nothing over and the
wet layer draws exactly as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Guesses are forgotten at every press start, so a lasso's or eraser's
  last guesses never reach a stroke written in the Zoom box.
- The input debug overlay shows pred=<share of frames with a tail>%
  <its mean length>px +<how far ahead the guesses reach>ms once guesses
  arrive; with the setting off the overlay is as it was.
- The row's line says who it is for, as Joost asked: "Experimental, for
  old or high-latency devices." (42 languages updated).
- freehand.ts names the opt-in exception to "nothing drawn ahead".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Joost-8
Joost-8 marked this pull request as ready for review December 4, 2026 03:48
@Joost-8
Joost-8 merged commit 217bac3 into main Dec 4, 2026
1 check passed
@Joost-8
Joost-8 deleted the claude/issue-287-predicted-ink-3b7ac8 branch December 4, 2026 03:48
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