Repository navigation
Draw ahead of the pen: an experimental setting for ink delay on old or high-latency devices (#287) - #419
Merged
Conversation
#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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 nogetPredictedEvents, 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
src/ink/predicted-tail.ts(in coverage), teststests/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.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).pred=).ink-surface.ts+12 andink-view.ts+1 lines of wiring; their caps infile-size.jsonare raised by that.Test on the device
On the Android tablet (Galaxy Tab or Oskar's), in a notebook:
lat ink …/frame …line (nopred=appears).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).Not verified
+msfigure will say); if it is past 12 ms, nothing is drawn andPREDICT_MAX_MSneeds raising.vault.mjs add 419was refused because another session holds the vault branch in its worktree.PREDICT_MAX_PXfrom Oskar's results.latfigures time the newest real sample, so they will not move with the tail; the feel is the measure.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