Pixi.js: Feature request: Fixed sprites length for BitmapText

Created on 9 Sep 2019  路  18Comments  路  Source: pixijs/pixi.js

I just took a look at BitmapText and I saw that it adds/removes sprites on demand and it's determined by text length. Wouldn't it be more preferred if that stays the same and just use visible: true/false and/or change texture on the unnecessary sprites or at least make it as a property or something like minSprites/maxSprites to avoid add/remove?
I work on crappy hardware and need as much performance as possible :)

Stale

All 18 comments

You can write extended BitmapText and implement yours mechanism of showing/hiding sprites.
Techinicaly visible and add/remove similar, but add/remove changes children's array.

BUT when you have 1000 glyphs and remove 999 from it then render loop check 1 from 1000, but when you use visible then render iterate 1000 from 1000 and check visible state. For low frequency changings it is more costly.

There are cases:

  1. Many static texts - add/remove.
  2. Many dynamic texts - visible + texture changing

The bigger purpose of BitmapText are high frequency changes so add/remove are less applicable or did I get you wrong?

I can always write my own stuff but I rather want a more suitable solution in the core.

I have a hunch that changing from addChild/removeChild to toggling visibility isn't going to be the performance win that you're hoping for... probably an imperceptible improvement? Allocating the Sprite and applying the transforms are probably more costly than pushing to the children list. BitmapText already recycles Sprites and your approach would still need to loop through each character anyways to set position based on the kerning metrics.

Would welcome some performance measurements to demonstrate the need. But we should start with that to fully understand the problem. If you can prove there's a meaningful difference, then we should talk about the best way to integrate and what API changes would be needed, if any. Otherwise, we will likely not consider this request.

I mainly work on smart tvs and the performance is way slower there than normal. My overall experience is that adding and removing sprites have way bigger impact on performance. Having sprite pools and not make changes to scenes with sprites is faster. I might not be so on browsers because my knowledge there is low.

For instance having scenes ready and just toggle visible I was able to make animated transitions between pages without spikes.

Benchmarks are required for this request.

Yep, I agree that its time to switch BitmapText to v5 batched mesh :) I'll help.

Yep, I agree that its time to switch BitmapText to v5 batched mesh :) I'll help.

Sounds amazing 馃槏

@ivanpopelyshev It would be pretty insane if you somehow could parse real font types (woff, woff2, ttf) and transform them into mesh. So you no longer need to provide those bitmaptext spritesheets. I don't know if this is possible but that would be pretty cool :)

I saw this:
https://github.com/bramstein/opentype

Sounds a lot like this plugin: https://github.com/PixelsCommander/pixi-sdf-text

@bigtimebuddy but that is not using the new stuff you guys implemented for v5?

I haven't upgraded to v5 yet so I'm a bit noob what's new :)
The only thing I've looked at so fair was the new Graphics things that looked amazing :)

I'm pretty sure that plugin is still v4.

@EloB
At the moment im working on Flash fonts implementation. all opentype fonts and their scaling will depend on that :)

@ivanpopelyshev I'm just curious... Have you had any time to investigate this feature? :)

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@ivanpopelyshev Any progress? It's sad to see this one disappear into eternity xD

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

We should鈥檝e closed this. @GoodBoyDigital merged in a new changes to BitmapText that uses Mesh instead of Sprites. Should be much faster!

I did see that someone had a working version of msdf for v5, though it looks like it needs a little work. https://github.com/cjsjy123/pixi-msdf-text-v5

Wonder how this would compare with regard to speed and clean zoom.

Was this page helpful?
0 / 5 - 0 ratings