TextChatService 'CoreScripts/ExperienceChatMain' Excessive CPU Usage

My game has been receiving lag spikes ‘recently’. The most obvious change I’ve made in the past few weeks was moving from the old chat system to ‘TextChatService’.

Asking some users for microprofile dumps, I can see that ‘Heartbeat/delayedThreads/Script_CoreScripts/ExperienceChatMain’ and ‘Heartbeat/delayedThreads/Script_Unknown’ are using >13ms of frametime very frequently. I do not believe I am doing anything out of the ordinary with the chat system. These lag spikes are having a negative effect on my game’s UX.

I can see calls to ‘GetFastFlag’ so I am confident that this is an issue with core scripts and not my game scripts.


Here are two relevant microprofiler dumps.

18 Likes

This is just an acknowledgment announcement!

We’ve filed a ticket into our internal database for this issue, and we will update you when we have further information!

Thanks for the report!

6 Likes

Hey @Cuyler, thanks for pointing this out. We are actively working on this. We’ll let you know when our optimizations make it to production!

7 Likes

Apologies but do you have a time frame? I’d love to use the new TextChatService system but I’m being forced to remove it. I’m getting a large amount of annoyed players saying they refuse to play with the amount of performance loss the new chat system is causing :confused:

Every one of them seems to be getting 8ms+ of frame time from the ExperienceChatMain core script whenever bubble chat is used.

EDIT: Seems like a recent update may have broken LegacyChatService’s bubble chat system, at least in Studio. I cannot get it to work in any place.

5 Likes

Still an issue.

5 Likes

This is still affecting the game by a lot
I noticed that it starts lagging as soon as someone with a chat tag sends a message

image

Might make another bug report because this is not being noticed while it actually affects my games with textchatservice

4 Likes

Another reproduction

4 Likes

I just wanted to provide a quick update. We’ve released several fixes aimed at improving the performance of various modules in ExperienceChatMain, which should improve performance for most users. We have a few other fixes in the works that we hope to release sometime this month. While we haven’t found a one-size-fits-all solution to resolve these performance issues completely, we are continuously working on incremental improvements.

5 Likes

If you don’t mind sharing, what exactly is making the new chat system slow? From an outside perspective, we’ve been confused as to what exactly is making this so much of an issue, given that a chat system implemented in Lua can get by fine without any hitches.

4 Likes

ExperienceChatMain for some reason still take a lot of time when you’re in a server with a lot of players and your device is under heavy load and there are people chatting and you’re typing in the chat too. But the lag spikes would still happen even if you don’t type in the chat or send any message. Here I played Doors in my Samsung Galaxy M12 phone at the maximum graphics quality level with Future Lighting, people were chatting in the lobby and I was typing in the chat too, the game was extremely slow and laggy, and for some reason ExperienceChatMain took a lot of time (over 100ms at times!).

Microprofiler logs:-
microprofile-20240802-162306.html (1.2 MB)
microprofile-20240802-162933.html (1.2 MB)

I am not sure if this is expected or not so I just decided to post this in case it isn’t.

Edit:- I don’t notice any huge spikes when I am in a private server and just typing myself without anybody else in the server other than me, in fact ExperienceChatMain tag doesn’t even show at all in the Microprofiler like in here:-

microprofile-20240802-163638.html (1.2 MB)

3 Likes

To add to this, I’ve tried playing Multi-Crew Tank Combat 4; a game that uses the Legacy Lua Chat System on my Samsung Galaxy M12 phone at the highest graphics quality level, with Future Lighting and this is how it looks like:-

microprofile-20240802-173003.html (1.5 MB)

1 Like

May I please add that the legacy chat has some errors that occur randomly in studio with ChatMain:

1 Like

I don’t think they’re going to fix any bugs with the legacy chat unless it’s a major bug since it is deprecated and is no longer being maintained. For example there is this bug report about “.Chatted Randomly Firing Twice in Public Experience Only” and there was a response from an engineer saying that they’re no longer maintaining the legacy chat system and won’t be able to fix the bug.

1 Like

Well that’s kind of unfair? Alot of games require legacy chat rather than the new version.

3 Likes

It would be fair if Roblox would bring back the missing features from the legacy chat system to the new TextChatService like tab support for example and fix the bugs and the performance issues with it. They literally want games to migrate to the new TextChatService without working out on why they aren’t doing so. I believe more games would migrate to the new TextChatService if the missing features and the bugs and performance issues got fixed.

3 Likes

But obviously they don’t, because the comapny is so cheap that even with billions of dollars they can’t afford to just hire some people to do so.

1 Like

I also want to add that spam opening the chat box still result in huge spikes from ExperienceChatMain mostly in servers with a lot of players. This is not related to VideoCaptureService:GetCameraDevices()

microprofile-20240808-111704.html (1.8 MB)
microprofile-20240808-112400.html (6.0 MB)

I don’t know what did the fixes that got released fixed because nothing really got fixed. The same performance issues remain.

2 Likes

This system is entirely built in Lua / React (although I think it was built using Roact and then put onto react-lua via roact-compat). I’ve forked a (slightly older, like 5 month old) copy to see if I could fix the performance issues and it is fairly challenging.

The chat loops through a large number of Adornees on Heartbeat, and given it’s run entirely in serial this eats up a huge chunk of CPU time at once, which tanks player FPS.

When I forked the BubbleChat though, I disabled the normal BubbleChat and it had no performance impact on ExperienceChatMain!

It looks like it has something to do with the UserProfiles module, I suspect being called for every player who has Chatted. Unfortunately nothing I can do to fix this except to revert back to Legacy chat since this is a critical issue for my game.

image

4 Likes

Seems that focusing on the chat as well as typing in the chat also cause lag spikes.


4 Likes

“React is a great idea for all of our core UI” - Statement dreamt up by the utterly deranged

This is captured from 1 minute of gameplay where no messages were sent nor was the chat window even shown. An empty chat accounts for HALF of our processing time. And this call graph is insane, how could you possibly need so many functions to (not even) display some text in a window?

It’s almost like the framework was made for a completely different medium. Oh wait…

6 Likes