Skip to content

BatchedText CPU performance bottleneck #362

@codedpalette

Description

@codedpalette

I'm using BatchedText to display large number (3000+) of Text objects in a single draw call. While my GPU rendering time is low, I noticed that about 30%-50% of my frame time is spent in the Text.onBeforeRender() method. I tried extending your classes to optimize the performance but without any luck. Do you have any ideas for potential optimizations? I'd be happy to create a PR if I'm successful, I just need a few pointers. Two potential ideas for improvement I noticed are checking for dirty flag on members in BatchedText._prepareForRender() loop, and caching computed uniforms in Text._prepareForRender(). My texts are mostly static, but I frequently change transformation matrices and clipRect, and also occasionally text alignment. I'm attaching the Chrome DevTools trace (taken with 4x CPU slowdown) so you can see the problem.

Trace-20250707T202647.json.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions