[Slate] Editor crash after successfully recompiling in-editor

I have a (otherwise perfectly working) projects that will not compile in-editor. More exactly it compiles, but the editor crashes immediatly after compiling. I did not launch the game or start PIE, this happens when simply pressing the “Compile” button.

Compiling from VS2013 is OK, running is OK, wether in PIE or Launch.

Here is the relevant log info :

[2014.04.05-10.17.17:541][193]LogWindows:Error:
appError called: Assertion failed:
!FindSlateStyle( SlateStyleName )
[File:D:\UnrealEngine\Engine\Source\Runtime\Slate\Private\SlateStyleRegistry.cpp]
[Line: 12]

Stack:
FWindowsPlatformStackWalk::StackWalkAndDump()
0x68baed6 + 0 bytes
[File=d:\unrealengine\engine\source\runtime\core\private\windows\windowsplatformstackwalk.cpp:177]
[in
D:\UnrealEngine\Engine\Binaries\Win64\UE4Editor-Core.dll]
FDebug::AssertFailed() 0x675f675 + 0
bytes
[File=d:\unrealengine\engine\source\runtime\core\private\misc\outputdevice.cpp:176]
[in
D:\UnrealEngine\Engine\Binaries\Win64\UE4Editor-Core.dll]
FSlateStyleRegistry::RegisterSlateStyle()
0xc576295 + 0 bytes
[File=d:\unrealengine\engine\source\runtime\slate\private\slatestyleregistry.cpp:14]
[in
D:\UnrealEngine\Engine\Binaries\Win64\UE4Editor-Slate.dll]
FSUIResources::Initialize() 0xfd9dec5e

  • 0 bytes [File=d:\sorcery\source\sorcery\gui\suiresources.cpp:27]
    [in
    D:\Sorcery\Binaries\Win64\UE4Editor-Sorcery-4637.dll]
    FModuleManager::LoadModuleWithFailureReason()
    0x67b7cd4 + 0 bytes
    [File=d:\unrealengine\engine\source\runtime\core\private\modules\modulemanager.cpp:376]
    [in
    D:\UnrealEngine\Engine\Binaries\Win64\UE4Editor-Core.dll]
    FModuleManager::LoadModule() 0x67b73b0
  • 26 bytes [File=d:\unrealengine\engine\source\runtime\core\private\modules\modulemanager.cpp:255]
    [in
    D:\UnrealEngine\Engine\Binaries\Win64\UE4Editor-Core.dll]
    RebindPackages'::21’::Local::DoHotReload()
    0x1038c2e0 + 26 bytes
    [File=d:\unrealengine\engine\source\runtime\coreuobject\private\uobject\obj.cpp:1876]
    [in
    D:\UnrealEngine\Engine\Binaries\Win64\UE4Editor-CoreUObject.dll]
    TBaseStaticDelegateInstance_TwoParams_ThreeVars * __ptr64,FDefaultAllocator>,TArray,FOutputDevice
    & __ptr64>::Execute() 0x1038e627 + 0
    bytes
    [File=d:\unrealengine\engine\source\runtime\core\public\templates\delegateinstancesimpl.inl:820]
    [in
    D:\UnrealEngine\Engine\Binaries\Win64\UE4Editor-CoreUObject.dll]
    TBaseStaticDelegateInstance_TwoParams_ThreeVars * __ptr64,FDefaultAllocator>,TArray,FOutputDevice
    & __ptr64>::ExecuteIfSafe() 0x1038e6fa
  • 0 bytes [File=d:\unrealengine\engine\source\runtime\core\public\templates\delegateinstancesimpl.inl:832]
    [in
    D:\UnrealEngine\Engine\Binaries\Win64\UE4Editor-CoreUObject.dll]
    FModuleManager::CheckForFinishedModuleDLLCompile()
    0x67a2a7b + 0 bytes
    [File=d:\unrealengine\engine\source\runtime\core\private\modules\modulemanager.cpp:1912]
    [in
    D:\UnrealEngine\Engine\Binaries\Win64\UE4Editor-Core.dll]
    FModuleManager::Tick() 0x67c779b + 90
    bytes
    [File=d:\unrealengine\engine\source\runtime\core\private\modules\modulemanager.cpp:68]
    [in
    D:\UnrealEngine\Engine\Binaries\Win64\UE4Editor-Core.dll]
    UEditorEngine::Tick() 0x32c4c45 + 0
    bytes
    [File=d:\unrealengine\engine\source\editor\unrealed\private\editor.cpp:830]
    [in
    D:\UnrealEngine\Engine\Binaries\Win64\UE4Editor-UnrealEd.dll]
    UUnrealEdEngine::Tick() 0x36d9ce6 + 0
    bytes
    [File=d:\unrealengine\engine\source\editor\unrealed\private\unrealedengine.cpp:212]
    [in
    D:\UnrealEngine\Engine\Binaries\Win64\UE4Editor-UnrealEd.dll]
    FEngineLoop::Tick() 0x1277593 + 0
    bytes
    [File=d:\unrealengine\engine\source\runtime\launch\private\launchengineloop.cpp:1959]
    [in
    D:\UnrealEngine\Engine\Binaries\Win64\UE4Editor.exe]
    GuardedMain() 0x126ce5c + 0 bytes
    [File=d:\unrealengine\engine\source\runtime\launch\private\launch.cpp:132]
    [in
    D:\UnrealEngine\Engine\Binaries\Win64\UE4Editor.exe]
    GuardedMainWrapper() 0x126ceca + 5
    bytes
    [File=d:\unrealengine\engine\source\runtime\launch\private\windows\launchwindows.cpp:120]
    [in
    D:\UnrealEngine\Engine\Binaries\Win64\UE4Editor.exe]
    WinMain() 0x1278ae9 + 17 bytes
    [File=d:\unrealengine\engine\source\runtime\launch\private\windows\launchwindows.cpp:196]
    [in
    D:\UnrealEngine\Engine\Binaries\Win64\UE4Editor.exe]
    __tmainCRTStartup() 0x12798d9 + 21 bytes
    [File=f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:618]
    [in
    D:\UnrealEngine\Engine\Binaries\Win64\UE4Editor.exe]
    Address = 0x227f15dd (filename not
    found) [in
    C:\WINDOWS\system32\KERNEL32.DLL]
    Address = 0x24fd43d1 (filename not
    found) [in
    C:\WINDOWS\SYSTEM32\ntdll.dll] Address
    = 0x24fd43d1 (filename not found) [in C:\WINDOWS\SYSTEM32\ntdll.dll]

Obviously a Slate issue, but this looks internal rather than user code, since no game is running.

I am using UE 4.02 from source.

1 Like

That looks like it’s tried to register your style set (FSUIResources) twice, presumably when the game module was loaded again after compilation.

I assume that when your module loads, you’re initialising your style, which is calling FSlateStyleRegistry::RegisterSlateStyle?

Do you also ever call FSlateStyleRegistry::UnRegisterSlateStyle when unloading your module?

That’s what I do yes, here is the two relevant methods :

void FSUIResources::Initialize()
{
	if (!m_UIResources.IsValid())
	{
		...
		FSlateStyleRegistry::RegisterSlateStyle(*m_UIResources);
	}
}

void FSUIResources::Shutdown()
{
	FSlateStyleRegistry::UnRegisterSlateStyle(*m_UIResources);
	ensure(m_UIResources.IsUnique());
	m_UIResources.Reset();
}

From the first method, I shouldn’t reload the style…

The resource is declared like this :

TSharedPtr<FSlateGameResources> m_UIResources

Okay, could you pop a breakpoint in those two functions, compile in the editor, and then let me know which breakpoints get hit. Thanks.

The first one (Initialize) is hit. The code follows through into the if, and calls RegisterSlateStyle which crashes the editor.

Curious, the module has been unloaded and reloaded without FSUIResources::Shutdown being called (hence the null pointer and re-initialisation).

Where are FSUIResources::Initialize and FSUIResources::Shutdown called from?

I redid the test, the Initialize method is called twice (once when starting, a second time after compiling) and Shutdown is never.

Shutdown is supposed to be called from the FProjectname::ShutdownModule() method, and it is really called when I exit the game cleanly, so I don’t get it.

Thanks, that sounds like it might be a bug with our hot-reload code.

Unfortunately I can’t check this right now, but I’ll make a note to check it on Monday when I get in to work and then get back to you.

Thanks a lot !

Okay, I’ve tried this with the ShooterGame sample and it does look like a bug.

Basically FModuleManager::AbandonModule doesn’t call ShutdownModule; I’m not 100% sure that it should, so I’m going to check and get that confirmed one way or the other.

As a workaround, AbandonModule does broadcast a ModulesChangedEvent with ModuleUnloaded as the reason, so you could hook in to that event and unload your style from it.

The following code should do that for you (replace ProjectName with the name of your game module).

void FProjectName::StartupModule()
{
	// ...

	FModuleManager::Get().OnModulesChanged().AddSP(this, &FProjectName::HandleModulesChanged);
}

void FProjectName::ShutdownModule()
{
	// ...

	// This will probably still be an issue as this won't get called when the module is abandoned, so you may end up with multiple delegates trying to unload your style. You may have to add a bool to guard against that in HandleModulesChanged.
	FModuleManager::Get().OnModulesChanged().RemoveAll(this);
}

void FProjectName::HandleModulesChanged( FName ModuleThatChanged, EModuleChangeReason::Type ReasonForChange )
{
	static const FName ProjectName("ProjectName");
	if(ModuleThatChanged == ProjectName && ReasonForChange == EModuleChangeReason::ModuleUnloaded)
	{
		FSUIResources::Shutdown();
	}
}

I have the exact same issue as Gwenn, and this solution has not resolved my issue. In fact, it made it worse: instead of crashing on compile, it crashes on editor load :slight_smile: I have tried recompiling from the command line, to no avail.

I’ve entered an internal bug regarding this issue, so hopefully it will get triaged soon.

Regarding the workaround I provided, how is it crashing? We use a similar method internally to handle some intermodule dependencies in the editor (which is where I lifted that code from).

I have the same log message as in this question: Slate Style crash the editor - UI - Unreal Engine Forums

It may be related to how my paths are defined, trying to figure it out.

I’ve still been attempting to get this to work. It crashes with this line in StartupModule:

FModuleManager::Get().OnModulesChanged().AddSP(this, &FSlateTest1::HandleModulesChanged);

To make it work I have had to implement an AsShared() function. is this how it should look?

TSharedRef<FSlateTest1> AsShared() { return TSharedRef<FSlateTest1>(this); }

The correct way to get an AsShared() function is to derive from TSharedFromThis, eg)

class FSlateTest1 : public TSharedFromThis<FSlateTest1>

I finally found the solution in ShooterGame, with a “hot reload hack” comment. Here, in StartupModule(), before firing up the style instance :

FSlateStyleRegistry::UnRegisterSlateStyle(YourStyleNameHere);

I tried it and it works at last ! I can recompile in the editor.

1 Like

wow, dude, your answer solved my problem, thanks!