Alright so I went ahead and took a peek into the CoreScripts to find out what was causing this, and what I found genuinely blew my mind.
The problematic code can be found in CoreScripts.Modules.Settings.Pages.Players
. The code in this file is responsible for the displaying of the list of players in the escape menu and I’m legitimately appalled that this code was allowed to ship to production.
The function that keeps calling BindToRenderStep()
wasn’t exactly hard to find, I just had to search for the name it used. Here it is:
What this function does is quite befuddling. See, it’s called resizeInspectButton
but what it actually seems to do is check whether the screen orientation just changed and if it did, destroy the old button, create a new one, and then on line 1165, create a new render step binding and unbind the old one. Hang on, that can’t be right, right? RIGHT???
Well let’s see what calls this function, maybe it’s not so bad. Nope! Turns out it’s called on line 1130 inside an event connection declared on line 1659! Would anyone like to guess what event this is? That’s right, it’s an event that gets fired every single time the parent frame’s size changes!
That’s right kids, we are destroying the old UI and constructing a new one every single time the screen orientation changes! Oh but it gets way worse! It does the same thing for the “add friend” and “block” buttons too! And it does this for every single entry in the player list! And who knows how many more instances of this there are throughout the rest of the escape menu’s code?
But hey, maybe I’m crazy. Maybe I’m misunderstanding something. Maybe I’m- Nope. It really is that bad.
Anyway I’m genuinely befuddled why there isn’t a rule enforced company-wide that all UI code that ships with studio or the client must be written with React, because this is just flat out bad practice. It’s virtually impossible to fall into a pattern like this when using React.
Gonna cc @Stickmasterluke here because he’s the one who wrote this file. Maybe he can shed some light on why things were done this way, because to me it makes zero sense and just wastes performance.