The VisibilityStateChanged signal in CoreGuiChatConnections fails to update the Topbar Chat icon's state

The VisibilityStateChanged signal, used with StarterGui:SetCore("CoreGuiChatConnections", containerTable) fails to update the visibility status of the chat in the topbar. With the LegacyChat (well, what is a modified version of), this results in the topbar chat button breaking, when the LegacyChat tries to set it to be visible (when using the hotkey to focus the chatbar)

While the LegacyChat is now deprecated, StarterGui:SetCore("CoreGuiChatConnections", containerTable) is still very useful for custom chats looking to integrate directly into the topbar

Note that, I think, this started happening around April of this year (while the LegacyChat was being phased out), and I remember the default LegacyChat having issues. I can’t confirm this, as I am unable to test with the stock LegacyChat. I’m also guessing a little about how this system is supposed to work, as I cannot use an older version of studio to test how it is supposed to behave, and there is no documentation about it. I am relying on the LegacyChat code to infer the expected behavior

If the chat is closed, and you try to open it by using the hotkey, it still thinks the chat is closed while it isn’t, but moreover, it’s in an odd state, where clicking the topbar button is also broken, meaning it is now impossible to truly “open” it
(At the end of the video, I try to click on the chat button to “open” it, and I also press é to (re)focus the chat, even though it is already focus, but that doesn’t magically fix it)

It is easier to see, in a repo I made. This repo also has the case where the button tells the topbar that the chat is closed (something the LegacyChat cannot do by default), and this does actually work at getting the topbar button out of its glitched stuck state

Repo file: CoreGuiChatConnections_bug.rbxl (63.7 KB)

A workaround I’ve found is to use StarterGui:SetCore("ChatActive", IsVisible) and the VisibilityStateChanged signal


System information:
– Windows 10
– Ryzen 5 5600G (integrated graphics)
– 16Gb drr4 ram 3200MHz

Expected behavior

I expect the VisibilityStateChanged signal, from StarterGui:SetCore("CoreGuiChatConnections", containerTable), to correctly update the status of the chat icon and notifications on the topbar

1 Like

This workaround seems to not work anymore.

  10:36:55.247   â–¶ Maximum event re-entrancy depth exceeded for BindableEvent.Event when calling anonymous function on line 20 in CoreGui.RobloxGui.Modules.ChatUtil (x4)  -  Studio
  10:36:55.249  Maximum event re-entrancy depth exceeded for BindableEvent.Event when calling anonymous function on line 814 in CorePackages.Workspace.Packages._Workspace.ExpChat.ExpChat.ChatInput.UI.ChatInputBar.ChatInputBar  -  Studio
  10:36:55.249  Maximum event re-entrancy depth exceeded for BindableEvent.Event when calling anonymous function on line 399 in CoreGui.RobloxGui.Modules.NewChat  -  Studio
  10:36:55.249  Maximum event re-entrancy depth exceeded for BindableEvent.Event when calling anonymous function on line 20 in CoreGui.RobloxGui.Modules.ChatUtil  -  Studio
  10:36:55.249  Maximum event re-entrancy depth exceeded for BindableEvent.Event when calling anonymous function on line 331 in CoreGui.RobloxGui.Modules.NewChat  -  Studio
  10:36:55.250   â–¶ Maximum event re-entrancy depth exceeded for BindableEvent.Event when calling anonymous function on line 20 in CoreGui.RobloxGui.Modules.ChatUtil (x2)  -  Studio

Make sure that when the function that listens to changes from the topbar is ran, if the state is identical to the previous state, return. Otherwise, if you fire the bindable to the CoreGui, it causes an infinite loop like this, because the coregui sends back a signal even if the state didn’t change

In the SetVisibility() function, there is the check to see if the visibility changed, before firing the VisibilityStateChanged bindable to the CoreGui

local WORKAROUND_FIX = true

local Button = script.Parent
local IsVisible = false

local function UpdateButton()
	Button.Text = IsVisible and "I am visible" or "I am NOT visible"
	Button.Transparency = IsVisible and 0 or 0.5
end
UpdateButton()

local function SetVisibility(Visible)
	if Visible == IsVisible then return end
	
	IsVisible = Visible
	UpdateButton()
	
	Chat.VisibilityStateChanged:fire(IsVisible)
	
	if WORKAROUND_FIX then 
		StarterGui:SetCore("ChatActive", IsVisible) 
	end
end

Chat.GetVisible = function(self)
	print("GETVISIBLE CALLED")
	return IsVisible -- Don't really know when this guy is used, it never seems to be used
end

Chat.SetVisible = function(self, Visible)
	SetVisibility(Visible)
end

Button.MouseButton1Click:Connect(function() 
	SetVisibility(not IsVisible)
end)
1 Like