Ensure condition failed: !IsGarbageCollecting()

This problem come from this:

There have two widget bp. A is main. B is a element in main. I drag some element from Palette to canvas to design a UI by UMG. The A was. when i’m working, maybe time’s up. Something happened. Maybe auto store or other i don’t known.

Them red error output into Output log window.

Here is stack.

Error: === Handled ensure: ===
Error: Ensure condition failed: !IsGarbageCollecting() [File:D:\UnrealEngine-4.20.1-release\Engine\Source\Runtime\UMG\Private\Slate\SObjectWidget.cpp] [Line: 41]
Error: SObjectWidget for 'ScrollBackgroundPanelWidget_C /Engine/Transient.World_1:MobileBag_C_2.WidgetTree_0.NealScrollBar' destroyed while collecting garbage.  This can lead to multiple GCs being required to cleanup the object.  Possible causes might be,
Error: 1) ReleaseSlateResources not being implemented for the owner of this pointer.
Error: 2) You may just be holding onto some slate pointers on an actor that don't get reset until the actor is Garbage Collected.  You should avoid doing this, and instead reset those references when the actor is Destroyed.
Error: Stack: 
Error: [Callstack] 0x00007ffecccf8e16 UE4Editor-Core.dll!FWindowsPlatformStackWalk::StackWalkAndDump() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\private\windows\windowsplatformstackwalk.cpp:235]
Error: [Callstack] 0x00007ffecca4f082 UE4Editor-Core.dll!FDebug::EnsureFailed() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\private\misc\assertionmacros.cpp:305]
Error: [Callstack] 0x00007ffecca67de6 UE4Editor-Core.dll!FDebug::OptionallyLogFormattedEnsureMessageReturningFalseImpl() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\private\misc\assertionmacros.cpp:436]
Error: [Callstack] 0x00007ffecb0980a3 UE4Editor-UMG.dll!SObjectWidget::~SObjectWidget() [d:\unrealengine-4.20.1-release\engine\source\runtime\umg\private\slate\sobjectwidget.cpp:41]
Error: [Callstack] 0x00007ffecbbb53b3 UE4Editor-SlateCore.dll!TIndirectArray<SBoxPanel::FSlot,FDefaultAllocator>::DestructAndFreeItems() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\public\containers\indirectarray.h:434]
Error: [Callstack] 0x00007ffecbb5c1b3 UE4Editor-SlateCore.dll!SBoxPanel::~SBoxPanel() []
Error: [Callstack] 0x00007ffecbbb52de UE4Editor-SlateCore.dll!TIndirectArray<SOverlay::FOverlaySlot,FDefaultAllocator>::DestructAndFreeItems() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\public\containers\indirectarray.h:434]
Error: [Callstack] 0x00007ffecbb5c3a3 UE4Editor-SlateCore.dll!SOverlay::~SOverlay() []
Error: [Callstack] 0x00007ffecbbb53b3 UE4Editor-SlateCore.dll!TIndirectArray<SBoxPanel::FSlot,FDefaultAllocator>::DestructAndFreeItems() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\public\containers\indirectarray.h:434]
Error: [Callstack] 0x00007ffecbb5c1b3 UE4Editor-SlateCore.dll!SBoxPanel::~SBoxPanel() []
Error: [Callstack] 0x00007ffecbbb52de UE4Editor-SlateCore.dll!TIndirectArray<SOverlay::FOverlaySlot,FDefaultAllocator>::DestructAndFreeItems() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\public\containers\indirectarray.h:434]
Error: [Callstack] 0x00007ffecbb5c3a3 UE4Editor-SlateCore.dll!SOverlay::~SOverlay() []
Error: [Callstack] 0x00007ffecbb5b4aa UE4Editor-SlateCore.dll!FSlotBase::~FSlotBase() [d:\unrealengine-4.20.1-release\engine\source\runtime\slatecore\private\slotbase.cpp:77]
Error: [Callstack] 0x00007ffecc0c24d2 UE4Editor-Slate.dll!TIndirectArray<SConstraintCanvas::FSlot,FDefaultAllocator>::DestructAndFreeItems() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\public\containers\indirectarray.h:435]
Error: [Callstack] 0x00007ffecc099dac UE4Editor-Slate.dll!SConstraintCanvas::~SConstraintCanvas() []
Error: [Callstack] 0x00007ffecbbb52de UE4Editor-SlateCore.dll!TIndirectArray<SOverlay::FOverlaySlot,FDefaultAllocator>::DestructAndFreeItems() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\public\containers\indirectarray.h:434]
Error: [Callstack] 0x00007ffecbb5c3a3 UE4Editor-SlateCore.dll!SOverlay::~SOverlay() []
Error: [Callstack] 0x00007ffecbb5b4aa UE4Editor-SlateCore.dll!FSlotBase::~FSlotBase() [d:\unrealengine-4.20.1-release\engine\source\runtime\slatecore\private\slotbase.cpp:77]
Error: [Callstack] 0x00007ffecc0c24d2 UE4Editor-Slate.dll!TIndirectArray<SConstraintCanvas::FSlot,FDefaultAllocator>::DestructAndFreeItems() [d:\unrealengine-4.20.1-release\engine\source\runtime\core\public\containers\indirectarray.h:435]
Error: [Callstack] 0x00007ffecc099dac UE4Editor-Slate.dll!SConstraintCanvas::~SConstraintCanvas() []
Error: [Callstack] 0x00007ffecb152a7b UE4Editor-UMG.dll!UCanvasPanel::ReleaseSlateResources() [d:\unrealengine-4.20.1-release\engine\source\runtime\umg\private\components\canvaspanel.cpp:25]
Error: [Callstack] 0x00007ffecdce050f UE4Editor-CoreUObject.dll!UObject::ConditionalBeginDestroy() [d:\unrealengine-4.20.1-release\engine\source\runtime\coreuobject\private\uobject\obj.cpp:901]
Error: [Callstack] 0x00007ffecdcb4176 UE4Editor-CoreUObject.dll!UnhashUnreachableObjects() [d:\unrealengine-4.20.1-release\engine\source\runtime\coreuobject\private\uobject\garbagecollection.cpp:1625]
Error: [Callstack] 0x00007ffecdc36afe UE4Editor-CoreUObject.dll!CollectGarbageInternal() [d:\unrealengine-4.20.1-release\engine\source\runtime\coreuobject\private\uobject\garbagecollection.cpp:1576]
Error: [Callstack] 0x00007ffecdc35e7e UE4Editor-CoreUObject.dll!CollectGarbage() [d:\unrealengine-4.20.1-release\engine\source\runtime\coreuobject\private\uobject\garbagecollection.cpp:1656]
Error: [Callstack] 0x00007ffec220f4b2 UE4Editor-UnrealEd.dll!FEditorFileUtils::AutosaveMapEx() [d:\unrealengine-4.20.1-release\engine\source\editor\unrealed\private\filehelpers.cpp:2507]
Error: [Callstack] 0x00007ffec24886bb UE4Editor-UnrealEd.dll!FPackageAutoSaver::AttemptAutoSave() [d:\unrealengine-4.20.1-release\engine\source\editor\unrealed\private\packageautosaver.cpp:195]
Error: [Callstack] 0x00007ffec27e2691 UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick() [d:\unrealengine-4.20.1-release\engine\source\editor\unrealed\private\unrealedengine.cpp:431]
Error: [Callstack] 0x00007ff7d93c5c0d UE4Editor.exe!FEngineLoop::Tick() [d:\unrealengine-4.20.1-release\engine\source\runtime\launch\private\launchengineloop.cpp:3495]
Error: [Callstack] 0x00007ff7d93d6aa0 UE4Editor.exe!GuardedMain() [d:\unrealengine-4.20.1-release\engine\source\runtime\launch\private\launch.cpp:166]
Error: [Callstack] 0x00007ff7d93d6b1a UE4Editor.exe!GuardedMainWrapper() [d:\unrealengine-4.20.1-release\engine\source\runtime\launch\private\windows\launchwindows.cpp:144]
Error: [Callstack] 0x00007ff7d93e3ef7 UE4Editor.exe!WinMain() [d:\unrealengine-4.20.1-release\engine\source\runtime\launch\private\windows\launchwindows.cpp:223]
Error: [Callstack] 0x00007ff7d93e5957 UE4Editor.exe!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:253]
Error: [Callstack] 0x00007ffef3d73034 KERNEL32.DLL!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffef6771461 ntdll.dll!UnknownFunction []

The detail process is i’m making a UI by UMG. I create a new widget and drag some Common element into. Them i drag some “User Created” element into. All of them are old and has used in other widget and fine.

Now i have lots of element in my new widget and some of them are default from editor, others are old and in using.

The old not just one. But after shoot time. error come in.

I don’t known how it happen.

It’s strange.

  1. All i used widget has used into other widget and fine.
  2. The error one create by right menu and inherit from User Widget. ReleaseSlateResource has implemented.
  3. The error one didn’t dynamically create. How to reset it when gc?

Widget structure like this

254388-question.png

So, how to solve it. I had encounter it in two widget.

My environment is Win10 enterprise, 4.20.1 source code.

I’m getting the same issue.

Make sure you pass the right value into the Owning Player input of the Create Widget node. It looks like the default got messed up in 4.20, and you have to set it explicitly now, unlike in previous engine versions.

Oh, too bad then. I’m starting to think that’s indeed a bug in 4.20. Today I’ve bumped into the same issue with UMG widgets that have the proper value for their Owning Player.

In my case it wasn’t something that happened when running the game, but just when opening the widget in the editor.

Reposting from UDN as we ran into it and one of the team found a fix


One of our team managed to track this down. Our project is based on an older version of ShooterGame - the newer versions of which have some updated code in ShooterGameViewportClient to Cleanup Slate Widgets when it the viewport client is destroyed.

He has updated ours to match, and the issue seems to have gone away. The ensure message was catching the issue, but the message was totally misleading.

void UShooterGameViewportClient::BeginDestroy()
{
    OldFocusWidget.Reset();
    LoadingScreenWidget.Reset();
    ViewportContentStack.Empty();
    HiddenViewportContentStack.Empty();

    Super::BeginDestroy();
}

I imagine a lot of folks are basing their games on ShooterGame, so hopefully this will allow others to fix this if they run into it. Added his additional comments here:

That also explains why I could fix that for BP widgets by passing the owner player in.

That puts them on the AddWidgetForPlayer path which uses the layer manager. The latter just adds the content to a special per-player widget, bypassing the viewport client

And that totally breaks the hidden widget stack in UShooterGameViewportClient

Add to Player Screen blueprint node works, but the previously used Add to Viewport node is bugged. Will cause the ensure failed error showing up in 4.20.

I had the same error, in my case, it was a widget that did not get removed from the parent widget, so what I did is go to the child widget that is mentioned in the ensure error and attach remove from the parent when I close the parent widget, hope this helps you

Same error. My solution was to add an IsValid before the Destroy incase it helps someone in the future.

I have a editor utility widget that adds a Widget Component to actors to display debug info(a little hacky). I don’t want this debug Widget Comp making it’s way into the game, so as a precaution, the Widget destroys itself on begin play after a delay.

I believe It was trying to destroy something that was already destroyed. My solution was to add an IsValid before the destroy.