Download

UMG - Adding/Clearing too many children makes UMG unresponsive?

I have a scenario where when a player walks by an object they can interact with, a button is added to a horizontal box on their main UMG widget. The exact flow does this

  1. Clear Children in horizontal box

  2. For each object the player can interact with…

  3. Create a new widget with the button and add it to the horizontal box

I have noticed that, after a while, this will stop responding. It gets “frozen”. Clear all children no longer removes anything and “add child” no longer adds anything. Any buttons that were on the players screen when this happens remain usable. The return value from subsequent “add child to horizontal box” calls will return a valid object. But nothing updates.

I thought maybe something wasn’t clearing right so maybe this gets provoked when you hit too many total children added. However I have had this issue happen with as few as 20 total children and as many as 200.

I have tried to reproduce this in a separate project by flooding a horizontal box with children and clearing them out rapidly but I couldn’t provoke the issue.
Here’s a video of the issue in action … it happened pretty quick for this recording: https://youtu.be/EO8PRuwqzPo

Here is the UMG code being called https://i.imgur.com/1OSY8nQ.png (removed all the debugging messages to make it cleaner for the screenshot)

I have no idea what I might be missing here but it’s driving me nuts!

From owning player it may help to add a get “Get Owning Player” or “get player”

Did you use overlap for this? Maybe you have “overlap in overlap” between objects, so when you trigger overlap for two objects it detects one “On end overlap”?

Sure, I can add it … any reason to think it might help here?

I am using overlap, yes. But I know the overlaps are working because I’m still getting my debug messages in UMG (see top left in video). The debugging was in the UMG code I posted, just removed it for the screenshot. My method is being called … but “Clear Children” no longer does anything to the widget. Neither does adding additional children.

[quote=“Chumble, post:4, topic:158387”]

Sure, I can add it … any reason to think it might help here?

It Just Ensures that the UMG is properly being linked to your character/controller and not randomly missing the correct link. Which could cause it to hiccup maybe.

Also do a check maybe to see if the same object is already overlapping. In your overlap, are you getting All overlapped objects? it could be getting bombarded with too many hits at once too if you sweep through a lot of objects at once.

What I would FIRST do is add each object to an array in the UMG ( you might need to do an “append array” )from the event then do a for each loop. this will ensure the objects are safely stored in the UMG before the for each and not have to dynamically send them every time.

[quote=“MindfieldsTech, post:5, topic:158387”]

Well, the server is detecting the overlaps and adds them one by one to an array on the player as actors are registered/unregistered. This array is set to rep notify. When the clients get this notify, it calls the refresh event in UMG with the updated list.

I can try switching the logic around to see if that helps … maybe have the list maintained clientside only and the server just tells the clients to update it. Then I can add/remove actors one by one clientside as they’re registered/unregistered.

Maybe you can try to use temp array (server only variable) to store data and add it to another array which is repNotify. In this way you wont flood server in for each loop with repNotify.
Or create a function on the server that will return array -> set your repNotify array. So you will send one array instead in loop.