Skip to content

Conversation

Zyie
Copy link
Member

@Zyie Zyie commented Jun 27, 2025

Reintroducing the caching logic for text we had in Pixi <= 8.9, but with a new, simplified approach.

Key Changes:

  • Simplified Caching Mechanism:
    This new implementation removes the somewhat fragile style-key tracking logic. Instead, it uses a much simpler uid + tick system to manage cached textures.
    This reduces the code complexity while still providing the benefits of texture caching when reusing the same text style.

    • This approach strikes a balance between performance and maintainability. While it's not as perfectly efficient as tracking every individual style change, it offers a middle ground that's far easier to maintain.
      For example, this would address use cases like #11465.

Simplifies caching for text by using unique identifiers and reference counting, reducing unnecessary texture regeneration and improving performance.

- Introduces a unique identifier for TextStyle instances.
- Implements reference counting for text textures to manage reuse.
- Removes redundant key generation logic.
Copy link

codesandbox-ci bot commented Jun 27, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit a8785a3:

Sandbox Source
pixi.js-sandbox Configuration

Copy link

pkg-pr-new bot commented Jul 23, 2025

pixi.js-basepixi.js-bunny-mark

npm i https://pkg.pr.new/pixijs/pixijs/pixi.js@11505

commit: 3f2c10b

@Zyie Zyie marked this pull request as ready for review July 28, 2025 10:31
Adds a cache to store measured text layouts, avoiding redundant recalculations and significantly improving performance when rendering the same text multiple times.

Adds a unique identifier to bitmap fonts for cache invalidation purposes.
Copy link
Member

@GoodBoyDigital GoodBoyDigital left a comment

Choose a reason for hiding this comment

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

I think we should either use a getter for styleKey
or rename the function to getStyleKey to remove any ambiguity.

@GoodBoyDigital
Copy link
Member

I would be happy to merge in

  • Reintroduced measureText Cache with LRU
  • Frozen Filters Array on TextStyle

right now 👍

Not against the additional caching on text - its just a lot of code to add back in and want to make sure it justifies the use cases!

@niusia-ua
Copy link

niusia-ua commented Aug 29, 2025

Hey guys. Thank you for your work.

When can we expect the release of this feature? Text objects are integral part of my app.

I just want to know whether should I implement the caching of text textures myself if this PR will take more time to merge, or it is reasonable to wait for the release.

@Zyie
Copy link
Member Author

Zyie commented Aug 29, 2025

When can we expect the release of this feature? Text objects are integral part of my app.

Hey, we are planning on getting this in for the next release, which should happen next week

@niusia-ua
Copy link

Awesome!

@Zyie Zyie added the ✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t label Sep 2, 2025
@Zyie Zyie added this pull request to the merge queue Sep 2, 2025
Merged via the queue into dev with commit e301117 Sep 2, 2025
8 of 9 checks passed
@Zyie Zyie deleted the feat/simple-caching branch September 2, 2025 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Why does v8.10.1 experience lag when using HTMLText? Bug: Heavy performance regression with many Text with 8.10.0
3 participants