fix(draw): guard against zero pressure pointer events#5693
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
4 Skipped Deployments
|
|
hmm testing with light strokes on a samsung tablet it can sometimes end a line with a 0 pressure point, which suggests that it might also sometimes start a line with a 0 pressure point. or if not samsung then maybe other tablets. |
|
also looking at the lines the affected user drew with this pr's preview deploy, all the points still have |
| this.isPenOrStylus = isPen || (z > 0 && z < 0.5) || (z > 0.5 && z < 1) | ||
| // if z === 0 on the initial point, treat this pen as a mouse because it's likely a broken pen | ||
| // or a broken OS. | ||
| this.isPenOrStylus = (isPen && z !== 0) || (z > 0 && z < 0.5) || (z > 0.5 && z < 1) |
There was a problem hiding this comment.
We'd need to test this across browsers. IIRC Safari (?) reports zero pressure in unusual scenarios, such as at the start of lines when using the Apple Pencil. I vaguely remember removing a zero check.
I actually wouldn't mind a "Input device: auto / mouse / pen" setting, similar to the "mousewheel behavior". Better input controls have been on my list forever.
|
Do we still want to work on this? |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
branching-chat-template | 592854d | Commit Preview URL Branch Preview URL |
Feb 13 2026, 08:04 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| 🔵 In progress View logs |
image-pipeline-template | 592854d | Feb 13 2026, 08:00 AM |
Replace the strip-from-start/end logic with a simple pressure clamp. Some pens or OSes report z=0 while the pen is touching, and stripping those points could remove most of the stroke. Clamping to a minimum pressure preserves all input points and also fixes existing saved documents with z=0 data. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
I replaced the strip-and-revert approach in Why: The original approach (strip low-pressure points from start/end, then revert if >50% were stripped) had two issues:
What changed: Instead of stripping points and potentially reverting, we now clamp any point with
The |
In order to keep the release notes current for the upcoming SDK release, this PR updates `apps/docs/content/releases/next.mdx` with documentation for recently merged changes. ### Changes - Add "What's new" section for the experimental `onDropOnCanvas` canvas drop handler (#7911) - Add API change entry for `TldrawOptions.experimental__onDropOnCanvas` - Update release intro paragraph to mention the new drop handler - Add bug fix entry for CJS compatibility regression from ESM-only rbush (#7905) - Add bug fix entry for zero pen pressure on tablets affecting draw shapes (#5693) ### Change type - [x] `docs` ### Test plan - [ ] Verify the release notes render correctly on the docs site ### Release notes - Update next release notes with experimental canvas drop handler, CJS fix, and tablet pressure fix
In order to keep the release notes current for the upcoming SDK release, this PR updates `apps/docs/content/releases/next.mdx` with documentation for recently merged changes. ### Changes - Add "What's new" section for the experimental `onDropOnCanvas` canvas drop handler (#7911) - Add API change entry for `TldrawOptions.experimental__onDropOnCanvas` - Update release intro paragraph to mention the new drop handler - Add bug fix entry for CJS compatibility regression from ESM-only rbush (#7905) - Add bug fix entry for zero pen pressure on tablets affecting draw shapes (#5693) ### Change type - [x] `docs` ### Test plan - [ ] Verify the release notes render correctly on the docs site ### Release notes - Update next release notes with experimental canvas drop handler, CJS fix, and tablet pressure fix
Add 12 new entries from PRs merged since v4.4.0: - Featured: click-through on transparent image pixels (#7942) - API: enum-to-const-object refactor (#8084) - Improvements: SVG sanitizer (#7896), save-on-blur (#8037) - Bug fixes: cross-origin download (#8090), zero-size draw (#8067), rich text toolbar cleanup (#8050), zoom threshold (#8040), selection foreground fallback (#8011), sticky note SVG shadow (#7934), arrow frame clamping (#7932), zero pressure draw (#5693)
We had a user of a Xiaomi tablet report that they couldn't draw anything, and after much debugging we discovered that their tablet was setting the pen pressure to 0 for every point. Interesting choice.
This PR accounts for that in two ways:
getStrokePoints, clamp any zero/near-zero pressure points to a minimum value (0.025) instead of stripping them. Previously, low-pressure points were stripped from the start and end of the stroke, which could remove most or all of the points when a device reportsz=0throughout. The old code had a 50% revert heuristic as a safety net, but reverting still left zero-pressure data in the points, producing near-invisible stroke sections. Clamping is simpler and also fixes existing saved documents withz=0data at render time.Change type
bugfixTest plan
Release notes
Note
Low Risk
Small, localized changes to pressure handling in the drawing pipeline; primary risk is subtle stroke-thickness behavior changes for low-pressure inputs.
Overview
Fixes an edge case where some tablets report
z=0pen pressure, which could prevent drawing or create near-invisible strokes.In
Drawing.startShape, pen input is no longer treated as pen/stylus when the initial pressure is0, causing the tool to use the non-pen (simulated) pressure path. IngetStrokePoints, replaces start/end low-pressure stripping with clamping all pressures to a minimum (0.025) when not simulating pressure, preserving points and improving rendering of existingz=0stroke data.Written by Cursor Bugbot for commit 28c7a07. This will update automatically on new commits. Configure here.