- Home /
TextMeshPro Performance Issues (Unity 5.6)
We're working on porting our game Tangledeep to Nintendo Switch, and part of that process is optimizing all aspects of the game to run at a smooth 60fps even on (relatively) low-end hardware. Unfortunately we're dealing with some noticeable, random hitches that appear to be the result of TextMeshPro methods.
Here's an example:
https://cdn.discordapp.com/attachments/157199747474522112/452260410603733003/unknown.png
And another one:
https://cdn.discordapp.com/attachments/157199747474522112/452259298404335623/unknown.png
These do NOT happen consistently or reliably. They are correlated to certain game actions but we haven't been able to reliably reproduce them, which makes it very frustrating to debug and optimize.
Our main canvas for the Player HUD uses Screen Space - Overlay, non-pixel perfect. There are a handful of TMPro elements for things like player health, XP, stamina, etc. Most frames, changing these numbers does not cause any noticeable spike at all.
We also use TMPro (NOT UGUI) for our flying 'damage number' popups, which are not on the canvas, but usually cause a big loss of performance from the SendWillRenderCanvases. Even so, sometimes this cost will be 5-10x higher than average on some frames because... why? We have no idea.
Any insight appreciated!
T$$anonymous$$Pro use shader to render text. The problem might be Text shadow or unlikely T$$anonymous$$Pro default shader does not support Nintendo Switch render target.
And flying text was problem maybe because in material shader settings have some Light emitting like outline text that cause to render shadow unnecessary.
This happens on PC as well, so it is not a Switch specific issue. In fact, the hitches are noticeable even on higher end PC hardware.
The material of the text is just "Distance Field", no other lighting, shadows, shaders, etc used.
Something was calling T$$anonymous$$Pro.SetText constantly like in a loop that force a text rebuild.
T$$anonymous$$Pro was using shader like i say. And it always expensive when instantiate new text with new material and not re-use premade text. $$anonymous$$aybe you didnt use pooling text?
We're not instantiating new text, it's all pooled from the start of the game. Also there is nothing calling SetText in a loop.