Add time to pointer inputs - #4443
Conversation
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.
There was a problem hiding this comment.
1 issue found across 2 files
Confidence score: 5/5
- In
desktop/src/input.rs, thetimevalue 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)timeconsistently 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
| 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.), |
There was a problem hiding this comment.
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>
|
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. |
b08f966 to
e00bb25
Compare
Will later be used for brushes that change over time