Add to viewport does not work

For some reason in my 5.1 project adding a widget to the screen does not show the widget. It worked in 5.0 exactly as it’s set up. It works in a new project too so I don’t understand what is different.

3 Likes

Hey there @Althaen! For replication purposes, could I see how you’d set up the BP? I can’t replicate Add to Viewport failing on my side as of yet, so we might have to identify where it could be failing.

Also, was this project migrated from 5.03 up to 5.1?

I was just trying to run a CreateWidget node into an AddToViewport node off BeginPlay. I am just going to start a new project and re-do my widgets.

Yes 5.0.3 to 5.1

Highly likely it’s a migration bug if we can’t replicate it in fresh 5.1 projects. I even migrated a project of mine with 3 different ways to add the widget and add to viewport and they all still worked (from 5.03 to 5.1)

Are there any errors generated when this occurs?

Aside from verifying the event is running at all with a breakpoint, not sure what else besides widget reflector to check it, but if nothing pops up, widget reflector won’t help.

Bug Reporting link:

After debugging a little, it appears that the Get() in AddToViewport in cpp returns nullptr therefore blocking the rest of the function.

Hey,

Any update on this ?
I have migrated my 5.0.3 project to 5.1.0 and now none of my “Add To Viewport” nodes are working.
The widget does not show up on screen so nothing happens in the widget reflector. “OnInitialized” event is fired when creating the widget but the “OnConstruct” event and the “Tick” event are not.
It looks like the “Add to Viewport” node just fails.

Hey there @Jed974! Welcome to the community! I don’t see a thread on the issues site for it listed. I hadn’t been able to replicate this on my side at all so tracking has been rough. That’s an excellent find though!

Does the widget get garbage collected immediately afterward or does the fade widget reference remain even after the fact?

It is not garbage collected no. I still retain the reference, can access it and can call events on the widget if I want to.

Hrm, alright so it doesn’t seem to be making it to the viewport subsystem at all due to the nullptr issue, but it’s actually being passed a reference. Try creating a brand new widget in 5.1 itself (not one of the migrated ones) and try this and let me know if it ended true or false.

This is definitely a bug of sorts, but figuring out what triggers it and also where in the pipeline it is might help.



Ok so I just created a new “DebugWidget” and it doesn’t show on screen and the IsInViewport returns false.
Does this help you ?

this is silly question but did you check game mode override?

What do you mean ?
What does this have to do with this issue ?

That does help! So it looks like exactly what you found out before it correct, it’s now receiving a nullptr regardless of how you put it through. The UI is being created and is not being attached. The bad news is that there’s basically no workaround for this unless I can find the trigger. I’m going to run a diff on the source to see if anything changed there or in the viewport subsystem that could have caused this. If neither it’ll be rough. Likely either source fixes and report it or we’ll have to wait on the official fix.

I’ve migrated one of my projects from 4.27 to 5.1 and am now experiencing this exact problem. I haven’t begun to debug it yet, but once I get around to it I’ll be sure to let you know if I find anything. Any help on this is appreciated.

I’ve tracked down the problem for myself and I assume it’s the same for you guys. My GameInstance class in CPP had overridden the Init and OnStart functions, and hadn’t called Super::Init(), etc. Make sure you’re calling the parent inits!

4 Likes

Ahhh! That could be why I couldn’t reproduce it at all, amazing work! Hey @Jed974 @Althaen, at your earliest convenience give this a try and let me know how it goes! Hopefully it’s universal and I can put it in my big book of migration fixes.

Hey !
Indeed ! Calling Super::Init() did fix the issue, thanks a lot !

1 Like

Hey Thanks for that fix guys!

1 Like

Yeah that was the issue.

1 Like

so is this an actual bug that would likely be fixed in 5.2?