Widget Invalidation Ensure and Crash in 5.7 update (FSlateCachedElementData::AddCache & FSlateInvalidationRoot::ClearAllFastPathData)

Following an update to 5.7 from 5.6.1, we’re seeing frequent crashes deep in the Paint of our hud content, normally around state changes (i.e. destroying the hud when we pause or hiding it on other events). The crash itself is hit when iterating over cached widgets from ClearAllFastPathData (as per the attached callstack), but on non-PC platforms we’re seeing a corresponding ensure firing some time before this, in FSlateCachedElementData::AddCache

FSlateCachedElementsHandle FSlateCachedElementData::AddCache(const SWidget* Widget)
{
#if WITH_SLATE_DEBUGGING
	for (TSharedPtr<FSlateCachedElementList>& CachedElementList : CachedElementLists)
	{
		ensure(CachedElementList->OwningWidget != Widget);
	}
#endif

This code just continues as normal after this point so we suspect an element is being referenced twice in cached lists and then either referenced after it’s destroyed or double freed - ‘OwningWidget’ is a raw pointer. We haven’t found an 100% solid repro yet but the timing seems variable, which would be consistent with a scenario like that.

As the callstack for the ensure contains invalidation boxes, we suspect some of the 7.1 changes in this area may be leading to the double-caching. It looks like this code has been updated since the 5.7 release was taken, so we’re speculating that these changes might help matters, but it’d be great if you could take a look and let us know if you think this is a likely path (and how easily we can cherry-pick the changes) - or any other potential fixes you can think of!

The main change we’re looking at is 48776307 (“This CL addresses three linked issues in the Dynamic Invalidation system…”), but that looks dependent on 47254763 (“Slate Invalidation - Show Slate Invalidation status in Diagnostic Window…”)

Thanks a lot!

Ian L

[Attachment Removed]

Hi,

To give a bit of context here, those changes referencing “Dynamic Invalidation” are part of some in-progress feature work which should still be disabled by default, though it’s reasonable to assume the changes might have affected existing invalidation workflows. I don’t see any reports matching your callstack so I’m not sure if any of the changes would address the crash you’re running into, but we do generally recommend upgrading to the latest hotfix as soon as possible so it may be worth trying that first if you haven’t already.

The ensure does give us a nice hint, implying that some SImage Widget is drawing elements into two different caches. There are some debug flags in the widget reflector that you can try enabling (also available via console commands), for starters I’d enable Slate.VerifyParentChildrenRelationship and see if that trips an ensure. This will check if any widget has multiple parents, which would explain how it ended up adding things into multiple caches. If it triggers, the log should point you to where the potential problem is.

Best,

Cody

[Attachment Removed]