I am experiencing an issue where a Widget Blueprint can lose references to assets used by widgets in its Widget Tree after compiling and saving the Blueprint.
The issue is not apparent while working in the editor or while running the game, as the widgets continue to appear and behave correctly. However, the missing references can be observed in the Reference Viewer.
Assets referenced by the widget will no longer be detected as dependencies and so may not be cooked.
From my testing, this appears to affect assets referenced through properties in the Widget Tree (ex: Material referenced in brush property of Image widget). Assets referenced through blueprint variables are unaffected.
This issue seems to only affect widget blueprint and not other blueprint types. All three repros appear to come down to the same underlying issue: objects being saved appear to copy over the RF_Transient flag that was set during widget blueprint compilation in LinkerLoad.cpp around line 705-715 in PRIVATE_PatchNewObjectIntoExport function.
// Since we don't copy the internal flags from Old to New, the mirrored flags for internal flags
// need to not be copied as well.
const EObjectFlags OldObjectFlags = OldObject->GetFlags() & ~(RF_MirroredGarbage);
// Detach the old object to make room for the new
OldObject->ClearFlags(RF_NeedLoad | RF_NeedPostLoad | RF_NeedPostLoadSubobjects);
OldObject->SetLinker(nullptr, INDEX_NONE, true /* bShouldDetachExisting */);
// Copy flags from the old CDO.
NewObject->SetFlags(OldObjectFlags);
Based on some testing I did, changing the logic to also exclude RF_Transient from OldObjectFlags that get copied over stops the issue from happening:
const EObjectFlags OldObjectFlags = OldObject->GetFlags() & ~(RF_MirroredGarbage | RF_Transient); However, since PRIVATE_PatchNewObjectIntoExport is fairly deep in the engine’s object loading/linking code, I am not confident that preventing RF_Transient from being copied here is the right solution to address the underlying problem.
Could you confirm if this behavior is a known issue?
More specifically:
- Is RF_Transient expected to be propagated from OldObject to NewObject in PRIVATE_PatchNewObjectIntoExport?
- If not, is there another location where the transient flag should be cleared to prevent these Widget Tree asset references from disappearing when the Widget Blueprint is compile and saved?
[Attachment Removed]
Steps to Reproduce
Repro A — Blank Project
- Create a texture asset.
- Create a new Widget Blueprint.
- Add an Image widget to the Widget Tree.
- Assign the texture to the Image’s Brush.
- Compile and save the Widget Blueprint.
- Open the Reference Viewer for the Widget Blueprint.
- Confirm that the texture appears as a dependency.
- Restart Unreal Editor.
- Open the Widget Blueprint.
- Compile and save it.
- Open the Reference Viewer again.
- Notice that the reference to the texture is now missing.
- Compile and save the Widget Blueprint again.
- Refresh the Reference Viewer.
- Notice that the texture reference has returned.
Further Compile and Save operations do not reproduce the problem until the editor is restarted again.
Repro B — Lyra
In Lyra, I can reproduce a similar issue repeatedly without restarting the editor.
Steps
- Open an existing Widget Blueprint that references other assets through its Widget Tree.
- Open the Reference Viewer and confirm that the expected references are present.
- Compile and save the Widget Blueprint.
- Refresh the Reference Viewer.
- Notice that references from the Widget Tree are now missing (ex: materials, textures, etc…)
- Compile and save the Widget Blueprint again.
- Refresh the Reference Viewer.
- Notice that the references are present again.
This can be reproduced repeatedly by compiling and saving the Widget Blueprint. The dependencies alternate between the expected and incorrect states.
I tracked this particular behavior to the call to LoadPackage() in Source\LyraEditor\Validation\EditorValidator_Load.cpp. Disabling this validator fixes the alternating issue from Repro B but does not fix the issue on first boot described in Repro A.
Repro C — Lyra / Adding a New Reference (side effect of Repro B)
I can also reproduce a similar issue where new references aren’t detected until a reboot.
Steps
- Open an existing Widget Blueprint that already references other assets through its Widget Tree.
- Open the Reference Viewer and confirm that the expected references are present.
- Add an Image widget to the Widget Tree.
- Set its Brush to an existing texture that was not previously referenced by the Widget Blueprint.
- Compile and save.
- Refresh the Reference Viewer.
- Notice that the existing references are now missing (due to issue described in Repro B).
- Compile and save again.
- Refresh the Reference Viewer.
- Notice that the previous references have returned, but the newly added texture reference is missing.
Workaround to bring back missing references:
- Reboot the editor.
- Open the Reference Viewer.
- Notice that all references except for the newly added texture reference are present.
- Save the widget without compiling.
- Refresh the Reference Viewer.
- Notice that all references are now correct.
[Attachment Removed]
Hi,
This looks to be resolved in 5.8, as I haven’t been able to reproduce your results. Could you try grabbing CL#50789595 and CL#50835672? Those look to be the most likely candidates for the fix, but if you’re still running into problems with those changes then I can keep digging to see if we’ve missed something.
Best,
Cody
[Attachment Removed]
Hello !
The provided CLs do fix the issue, thank you for the help 
[Attachment Removed]