UMG Widget blueprint canvas is not set correctly for the first frame

I loaded a Widget Blueprint in the BeginPlay event of the game mode and the UI is visible, but the buttons are not in the correct position until one frame has passed (shown in this video, I slowed the editor down to 3 fps to show):

This also happens in the simulation tab in the widget blueprint editor.
How do I fix this?

Sounds like a job for Force Layout Prepass. Add the node to the Construct event and target the container that holds the buttons.

See if that helps. Not 100% certain this is the solution but it’s worth trying.


Alternatively, you could wait for a frame and then show the widget.

1 Like

Calling Force layout prepass in the construct event didn’t work; I needed to hide it initially and then show the widget after a frame. Seems like it is a bug as shown on the issues list here Unreal Engine Issues and Bug Tracker (UE-137604)

Are you using a scale box? I wonder if calling prepass for the entire widget before adding it to the viewport / container would fix this. Seems like it’s related, the bug you refer to mentions prepassing the layout improves the behaviour, albeit does not fix it.

I’m not using a scale box but i just tried and it doesn’t fix the problem (neither does calling prepass before adding it to the viewport).

1 Like

I’m also having this issue with a loading screen. I took the lyra loading screen code, and the first frame shows my text looking wrong. No amount of ForceLayoutPrepass can fix this, which seems like it’s caused by a bug.

The problem is, this first frame is very long and lasts the duration of the map load. If the bug isn’t fixed, I’ll have to preshow the loading screen before starting a level transition.