[Repro] Adding UUserWidget To Viewport on BeginPlay Causes Crash On Clients
This occurs in Older builds of the engine as well, as far back as when UUserWidget was even a thing (4.5 I believe)
On BeginPlay in my HUD, I'm creating some widgets and attempting to add them to the Viewport. If I do this, any client that I run in the editor AND in a standalone game causes a crash at Actor->GetWorld(). I previously did this in Blueprint, and had to use a Delay node to prevent this crash from happening.
I suspect this is because it's trying to get a World from the PlayerController I'm passing in, whereby the World may not exist yet.
In C++, I'm now forced to create a timer to delay the creation of the widgets, to make sure there is enough time for the World to be created. This seems to be a fundamental issue with the way in which UserWidgets are never bound to a world (indeed, they remain in the viewport even if the game has moved to a different level entirely).
I would have thought this is a pretty regular place for people to want to create Widgets, at the start of the game - so this has to be a bug right? Anything I need to do at the start of the game for my widgets ALSO has to be delayed, so this isn't a very nice workflow.
This bug report is also linked to previous reports I have made, which have gone unresolved for now (I now have a reliable repro). https://answers.unrealengine.com/questions/166546/repro-using-umg-causes-garbage-collection-crash-on.html https://answers.unrealengine.com/questions/202764/server-travel-doesnt-remove-existing-viewport-widg.html
Here is the code I'm using (In my HUD class) to spawn my Widgets. The same behaviour can be achieved using Blueprints too. Simply create a user widget (pass in Owning Playing) and add it to viewport on Begin Play in the HUD - then start a multiplayer game in the editor.
asked May 30 '15 at 12:33 PM in C++ Programming
We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.
answered Jun 08 '15 at 06:38 PM
Rudy Q ♦♦ STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here