# Input lag when creating and removing widget button (Also can break player's input and potential memory leaks)

**URL:** <https://forums.unrealengine.com/t/input-lag-when-creating-and-removing-widget-button-also-can-break-players-input-and-potential-memory-leaks/2016748>\
**Category:** Issues and Bug Reporting\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, bug-report, fortnite\
**Created:** [September 11, 2024, 7:43pm UTC](https://forums.unrealengine.com/t/input-lag-when-creating-and-removing-widget-button-also-can-break-players-input-and-potential-memory-leaks/2016748 "2024-09-11T19:43:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![UselessMouth](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/uselessmouth/32/976514_2.png) [@UselessMouth](https://forums.unrealengine.com/u/UselessMouth)\
**Post date:** [September 11, 2024, 7:43pm UTC](https://forums.unrealengine.com/t/input-lag-when-creating-and-removing-widget-button-also-can-break-players-input-and-potential-memory-leaks/2016748/1 "2024-09-11T19:43:25Z")

</div>

### Summary

Widget creation takes a huge processing time.

### Please select what you are reporting on:

Verse

### What Type of Bug are you experiencing?

UI/Tools

### Steps to Reproduce

Make a button like in this tutorial under «Button Interactions» — [Making Widgets Interactable in Unreal Editor for Fortnite | Fortnite Documentation | Epic Developer Community](https://dev.epicgames.com/documentation/en-us/uefn/making-widgets-interactable-in-unreal-editor-for-fortnite)

### Expected Result

1. Button should appear instantly on the screen after widget creation.
2. Button should disappear instantly from the screen after widget removement.

### Observed Result

1. Player triggers something in the game that invokes button creation procedure code which includes `AddWidget()`.
2. Player’s input gets consumed by widget instantly, but there is no button on the screen.
3. Player waits around 1 second, unable to do anything.
4. Button appears on the screen allowing to interact with it.
5. You click on a button that invokes button removing procedure code which includes `RemoveWidget()`.
6. Button stays on the screen around 1 second, player is unable to do anything.
7. Player finally regains control of the character.

### Platform(s)

All

### Additional Notes

See the first reply for additional links.

The workaround for all of this should probably be like this:

1. Initialize widgets on first spawn of the player.
2. Hide the widgets until needed.
3. Show widgets when needed, consuming player’s input for button interaction.
4. Hide widgets when player is done with button interactions, allowing player to regain control of the character.

Though you can not use this workaround right now, because the widget consumes player’s input on its creation, disallowing to change input when needed — only by removing widget player can regain control, but removing widget process is slow and, as I found out, the widget doesn’t actually get properly removed from the memory, introducing memory leak, which can slow down the server.

You can find potential memory leak code in the first reply.

About breaking player’s input:

1. Create widget, which consumes player’s input.
2. Hide the widget from the screen (do not actually remove it from the code).
3. Player is unable to do anything in-game — player can only invoke Game Menu and that is all.

---

<div class="post-metadata">

**Author:** ![UselessMouth](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/uselessmouth/32/976514_2.png) [@UselessMouth](https://forums.unrealengine.com/u/UselessMouth)\
**Post date:** [September 11, 2024, 7:46pm UTC](https://forums.unrealengine.com/t/input-lag-when-creating-and-removing-widget-button-also-can-break-players-input-and-potential-memory-leaks/2016748/2 "2024-09-11T19:46:41Z")

</div>

### My original thread with the issue:

> [@\[BUG\] Huge input lag when using UI widget buttons — Also you can break player inputs entirely](https://forums.unrealengine.com/t/bug-huge-input-lag-when-using-ui-widget-buttons-also-you-can-break-player-inputs-entirely/2015799):
>
> So if you create buttons through Verse code, like in [this tutorial](https://dev.epicgames.com/documentation/en-us/uefn/making-widgets-interactable-in-unreal-editor-for-fortnite), when you do something for button to appear, you wait almost 1 second (!) to be able to see and click the button. Same goes for button closing. When you click on a button for it to disappear you wait almost 1 second (!!!) before it disappears and player regains control of the character. I am 100% sure this huge lag happens because of these two functions: player\_ui.AddWidget() # and player\_ui.RemoveWidget() So I tried to use w…

### Additional old threads:

> [@Trying to change the InputMode := ui\_input\_mode.None](https://forums.unrealengine.com/t/trying-to-change-the-inputmode-ui-input-mode-none/1896799):
>
> Hi I am tying to create an interactable Canvas that can appear and disappear with 0 delay I am saving already the Canvas in a map and I use it every time I need it. The delay is pretty low, but I need it to be 0 Canvas:=MakeCanvas() set AllAgentsCanvasUI[Agent] = option{Canvas} The only way that I found to get a perfect delay is using the functions Canvas.SetVisibility(widget\_visibility.Collapsed) / Canvas.SetVisibility(widget\_visibility.Visible) the problem is, you can not change player\_ui…

> [@Does anyone else find Verse UI really slow?](https://forums.unrealengine.com/t/does-anyone-else-find-verse-ui-really-slow/1309552):
>
> I have been messing around with different UI to create a shop in FN. I originally created a widget and dialog device but that has a few issues. Firstly, you can’t really change anything about the UI at runtime. Secondly, we are stuck with an extremely low 6 buttons (5 if you want to take one out for a exit button). These issues led me to the terrible verse UI code. The benefit here was that I could create more than 6 buttons and bind them all. What I did not expect was just how slow the UI is. …

### Potential memory leak code to reproduce:

> <https://gist.github.com/MattRix/912fd98e498a3e653457986bd65e8f94>

---

<div class="post-metadata">

**Author:** ![UselessMouth](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/uselessmouth/32/976514_2.png) [@UselessMouth](https://forums.unrealengine.com/u/UselessMouth)\
**Post date:** [September 25, 2024, 8:06am UTC](https://forums.unrealengine.com/t/input-lag-when-creating-and-removing-widget-button-also-can-break-players-input-and-potential-memory-leaks/2016748/3 "2024-09-25T08:06:03Z")

</div>

There’s an old thread about memory leak:

> [@Bug - Permanent server slowdown caused by potential memory leak when creating UI widgets from Verse](https://forums.unrealengine.com/t/bug-permanent-server-slowdown-caused-by-potential-memory-leak-when-creating-ui-widgets-from-verse/836064):
>
> If you create a bunch of UI widgets every frame/tick and remove and recreate them the next frame, over and over, gradually your server will run slower and slower. Once the server is running slow, you have to end the session and start a new one in order to get back to normal (which probably just moves you to a new server). I’ve tried this with creating 100 widgets per tick and the server became almost immediately unresponsive. With 30 widgets per tick, the effect is more gradual, but if you leav…

---

<div class="post-metadata">

**Author:** ![Flak](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/flak/32/769441_2.png) [@Flak](https://forums.unrealengine.com/u/Flak)\
**Post date:** [October 23, 2024, 12:27pm UTC](https://forums.unrealengine.com/t/input-lag-when-creating-and-removing-widget-button-also-can-break-players-input-and-potential-memory-leaks/2016748/5 "2024-10-23T12:27:58Z")

</div>

> [@Bug-Reporter](#):
>
> FORT-796013

Thank you for the report, this will be fixed in a future update.

---

<div class="post-metadata">

**Author:** ![Bug-Reporter](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bug-reporter/32/1223650_2.png) [@Bug-Reporter](https://forums.unrealengine.com/u/Bug-Reporter)\
**Post date:** [January 8, 2025, 2:27pm UTC](https://forums.unrealengine.com/t/input-lag-when-creating-and-removing-widget-button-also-can-break-players-input-and-potential-memory-leaks/2016748/6 "2025-01-08T14:27:16Z")

</div>

FORT-796013 is ‘Closed’ as ‘Fixed’. The issue will be addressed in 34.00.
