Skip to content

Conversation

@chromium-wpt-export-bot
Copy link
Collaborator

@chromium-wpt-export-bot chromium-wpt-export-bot commented Nov 4, 2025

When SVG paths use vector-effect="non-scaling-stroke" with large
viewBox coordinate translations (e.g. viewBox="2137678 0 96 50"),
vertical lines would disappear due to floating-point precision loss
in the transform calculations.

The issue occurred because ComputeNonScalingStrokeTransform() was
zeroing out translation components (SetE(0), SetF(0)) under the
assumption that "stroke width is independent of translation."
While this is true for stroke width calculation, removing
translation can lead to large coordinate values, increasing the
risk of precision loss as seen in the bug.

In this CL, we preserve translation components in the
non-scaling-stroke transform. This mitigates the precision loss
caused by large offset but we only preserve this translation for
non-scaling-stroke-path and not in general.

Bug: 40718465
Change-Id: Id92acf5c5798eab264df33d8a4af4759376483f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7106499
Reviewed-by: Fredrik Söderquist <[email protected]>
Reviewed-by: Vinay Singh <[email protected]>
Commit-Queue: Divyansh Mangal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1540470}

translations

When SVG paths use vector-effect="non-scaling-stroke" with large
viewBox coordinate translations (e.g. viewBox="2137678 0 96 50"),
vertical lines would disappear due to floating-point precision loss
in the transform calculations.

The issue occurred because `ComputeNonScalingStrokeTransform()` was
zeroing out translation components (SetE(0), SetF(0)) under the
assumption that "stroke width is independent of translation."
While this is true for stroke width calculation, removing
translation can lead to large coordinate values, increasing the
risk of precision loss as seen in the bug.

In this CL, we preserve translation components in the
non-scaling-stroke transform. This mitigates the precision loss
caused by large offset but we only preserve this translation for
non-scaling-stroke-path and not in general.

Bug: 40718465
Change-Id: Id92acf5c5798eab264df33d8a4af4759376483f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7106499
Reviewed-by: Fredrik Söderquist <[email protected]>
Reviewed-by: Vinay Singh <[email protected]>
Commit-Queue: Divyansh Mangal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1540470}
Copy link
Collaborator

@wpt-pr-bot wpt-pr-bot left a comment

Choose a reason for hiding this comment

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

The review process for this patch is being conducted in the Chromium project.

@chromium-wpt-export-bot chromium-wpt-export-bot merged commit 06b3899 into master Nov 5, 2025
25 checks passed
@chromium-wpt-export-bot chromium-wpt-export-bot deleted the chromium-export-cl-7106499 branch November 5, 2025 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants