"Set timer by event" prevents widget from being destroyed

If I use looping “Set Timer by Event” in a widget blueprint then remove that widget from parent, it never gets destroyed. After creating and removing this kind of widget from parent hundreds of times causes significant fps decrease. Because there are hundreds of instance of that widget and they don’t get destroyed.

Expected: Widget should be destroyed after it is not being called by another actor for a period.

Result: It is never being destroyed and never stops working so it is causing low fps on mobile devices if there is an expensive operations in the timers custom event.

–Here is longer version of this bug report:–

I have a widget with a looping timer. Every 5 seconds, it is refreshing it’s content which is a little bit slow operation. But, even if I remove this widget from parent, this timer never stops. If a create this widget 100 times and remove all of them from parent, they continue to working and in mobile device fps extremely decreases.

To reproduce:

  1. Create a widget blueprint. Name it “MySlowWidget”

  2. Set a looping “Timer by event”. Write 5 into seconds input.

  3. In the custom event of the timer, do iterating very expensive operations that can slow down a mobile device.

  4. Create “Close” button in this widget that removes this widget from parent.

  5. Implement a way to execute “Create MySlowWidget->Add to Viewport”. For example implement this to “Anroid Back” button in your player controller class.

  6. Package the game in development mode to the slowest android device that you can find.

  7. Press “Anroid Back” button to create the widget.

  8. Observe fps. It should be decreasing when timer is calling the event. If fps is not decreasing, go back to step 3 and use more expensive functions it the event that is called by timer. If you are able to see fps decrease, continue to next step(9).

  9. Remove created widget from parent by tapping the close button, which you created in step 4.

  10. Recreate widget with “Android Back” button.

  11. Do 9th and 10th steps tens of times.

  12. Close the widget if it is not and now observe fps.

Expected: No significant performance decrease

Result: Fps is around 10

Hello ,

After reading over your post, this appears to be working as intended. Removing a widget does not signal the death of it. It’s garbage collected like any other UObject. This means that it remains in memory until garbage collected. I have provided a link to a similar issue. You will see that it was closed as won’t fix. I hope that this information helps.

Link: Unreal Engine Issues and Bug Tracker (UE-22560)

Make it a great day

It is weird that working timer prevents pending widget from destroying though.