Closed Bug 1801463 Opened 1 year ago Closed 1 year ago

Categories

(Core :: SVG, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
111 Branch
Tracking Status
firefox111 --- fixed

People

(Reporter: mayankleoboy1, Assigned: jfkthame)

References

Details

Attachments

(1 file)

The profile here is dominated by FlattenedPath::ComputePointAtLength, which is getting called repeatedly to position each glyph along the path. With a long path, this gets really expensive as we iterate through the path operations from the beginning each time.

It looks like we could significantly improve the performance here with a simple "cursor" in FlattenedPath, so that when iterating forwards to position each glyph, we continue from the previous position instead of starting over.

This enables my local build to achieve 60fps on the js1k demo linked from the bug,
whereas without the patch I get barely 10fps.

Note: it's still possible for ComputePointAtLength would perform poorly if
the caller is iterating backwards or doing random access to a long path.
A potential mitigation for that would be to add an mLength field to FlatPathOp,
storing the length-so-far of the path, so that ComputePointAtLength could do
a binary search instead of linear accumulation. But this would add significant
memory overhead, and may not be worth doing; the low-overhead cursor here
appears to be enough to make text-on-a-path perform much better.

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED

bug 1801307 appears to be using an analogous approach in gpu-canvas.

See Also: → 1801307
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/100b45bcf622
Use a cursor in FlattenedPath to accelerate successive calls to ComputePointAtLength for SVG text-on-a-path layout. r=gfx-reviewers,nical
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 111 Branch

This is much better now : https://share.firefox.dev/3lcNOiI
Thanks very much for the fix!

QA Whiteboard: [qa-111b-p2]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: