Optimizing chat made with Babylon GUI

Hello! I’ve tried making chat for my game with usage of Babylon GUI. However, when it is active, rendering starts to lag (and texImage2D takes 27% of time from way less without it). It uses modified version of TextBlock, so I can have multiple colors/fonts in it.

I tried to recreate scene with playground, but it didn’t work, so here is code.

Code of chat (MIT License):

Modified TextBlock

The getUI function returns fullscreen AdvancedDynamicTexture.

Without a repro PG it’s going to be hard to help.

Also, do you have the same problem if using the non modified TextBlock control?

With TextBlock it’s little faster, but still far from optimal

Okay, so I found the source of problem. It was problem with my Multi-Scene GUI setup. I’ve moved guis to main scene and it works now without any problem!