Skip to content

Add time to pointer inputs - #4443

Open
timon-schelling wants to merge 2 commits into
route-pointer-inputsfrom
pointer-input-time-pr
Open

Add time to pointer inputs#4443
timon-schelling wants to merge 2 commits into
route-pointer-inputsfrom
pointer-input-time-pr

Conversation

@timon-schelling

Copy link
Copy Markdown
Member

Will later be used for brushes that change over time

The brush trace's hot core is position plus per-sample time, and the
frame clock is too coarse for high-rate tablets: several samples share
one timestamp and speed dynamics see dt = 0. The desktop stamps
editor-routed pointer input with a monotonic arrival time since winit
does not surface hardware timestamps; the web path can thread the
PointerEvent timeStamp through later.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Confidence score: 5/5

  • In desktop/src/input.rs, the time value is milliseconds since app startup on desktop but remains unset on web/editor paths, which can cause cross-platform event-timing inconsistencies or misordered input handling for consumers that assume comparable timestamps — document the unit/epoch and populate (or explicitly gate) time consistently across all paths.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="desktop/src/input.rs">

<violation number="1" location="desktop/src/input.rs:194">
P3: `time` stores an undocumented unit and epoch: `self.start.elapsed().as_secs_f64() * 1000.` yields milliseconds since app startup, and the field is never populated on the web/editor path (it stays `Default`/`None` there). Since this will later drive time-varying brushes, the magnitude and unit should be explicit and the desktop/web inconsistency documented, per the team's preference for precise, consistent naming. Add a doc comment stating the value is milliseconds since app start (or rename to `time_ms`), and note that it is currently desktop-only.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread desktop/src/input.rs
PointerState {
editor_position: (self.pointer_position.x / self.scale(), self.pointer_position.y / self.scale()).into(),
mouse_keys: self.pointer_keys,
time: Some(self.start.elapsed().as_secs_f64() * 1000.),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: time stores an undocumented unit and epoch: self.start.elapsed().as_secs_f64() * 1000. yields milliseconds since app startup, and the field is never populated on the web/editor path (it stays Default/None there). Since this will later drive time-varying brushes, the magnitude and unit should be explicit and the desktop/web inconsistency documented, per the team's preference for precise, consistent naming. Add a doc comment stating the value is milliseconds since app start (or rename to time_ms), and note that it is currently desktop-only.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/src/input.rs, line 194:

<comment>`time` stores an undocumented unit and epoch: `self.start.elapsed().as_secs_f64() * 1000.` yields milliseconds since app startup, and the field is never populated on the web/editor path (it stays `Default`/`None` there). Since this will later drive time-varying brushes, the magnitude and unit should be explicit and the desktop/web inconsistency documented, per the team's preference for precise, consistent naming. Add a doc comment stating the value is milliseconds since app start (or rename to `time_ms`), and note that it is currently desktop-only.</comment>

<file context>
@@ -189,6 +191,7 @@ impl InputState {
 		PointerState {
 			editor_position: (self.pointer_position.x / self.scale(), self.pointer_position.y / self.scale()).into(),
 			mouse_keys: self.pointer_keys,
+			time: Some(self.start.elapsed().as_secs_f64() * 1000.),
 			..Default::default()
 		}
</file context>

@TrueDoctor

Copy link
Copy Markdown
Member

Would it potentially make more sense to store a unix epoch here? or animation time?

@timon-schelling

Copy link
Copy Markdown
Member Author

Would it potentially make more sense to store a unix epoch here? or animation time?

Anything that can capture the notion of this sample was captured x seconds after the stroke began.

This small change is s separate PR for this exact discussion.

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.

2 participants