4.13+ Plugin custom Kismet BP Node: Standalone game crash

I have a custom UK2Node in a Plugin Editor-only Module. If I add the node to a BP, Play Standalone Game crashes.

Happens in 4.13 and 4.14, but not in 4.12 ! Also works fine in Simulate and Packaged.

AFAIK the custom node is expanded (as in ExpandNode is called), but the node is serialized in the compiled blueprint. So, when Standalone game loads the blueprint, the node fails to load (because it’s an Editor-only class), then it crashes in a UEdGraphPin de-serialize because it seems there is still a node with a pin to my node (which is null now).

Here is a very small Plugin and steps to reproduce of the bug:

  • download the TestNodePlugin plugin
  • add the TestNodePlugin to a project
  • open a Level and its Level Blueprint
  • add the blueprint function “Test Node Plugin”
  • plug exec pin from “Begin Play” to “Test Node Plugin”
  • launch Standalone game
  • crash

Relevant logs when I launch Standalone Game:

[  0]LogLinker:Warning: Can't find file '/Script/TestNodeEditorPlugin'
[  0]LogUObjectGlobals:Warning: Failed to load '/Script/TestNodeEditorPlugin': Can't find file '/Script/TestNodeEditorPlugin'
[  0]LogLinker:Warning: Can't find file for asset '/Script/TestNodeEditorPlugin' while loading NULL.
...
[  0]LoadErrors: Info Failed to load /Script/TestNodeEditorPlugin.BPNode_TestNode Referenced by EventGraph
...
Assertion failed: LocalOwningNode [File:D:\Build\++UE4+Release-4.13+Compile\Sync\Engine\Source\Runtime\Engine\Private\EdGraph\EdGraphPin.cpp] [Line: 1449] 
...
UE4Editor.exe has triggered a breakpoint.

The asserts seems to happen when de-serializing the exec pin in the “Begin Play” node.

Everything seem legit, the only bug I see is that my “Test Node Plugin” function is serialized in the compiled blueprint instead if it being expanded and removed.

I cannot even workaround by putting my node in the “Game” Module, because UnrealHeaderTool wont see my #if WITH_EDITOR around the class, and does not know about UK2Node in Game build.

I still hope it’s my fault, if not, it means I still don’t have a workaround, and will need to wait for a fix in the Engine.

Also, any workaround ideas is welcome !

Edit: typo

I just found a workaround: if I manually load my Editor module from my Game module, everything loads.

Just to be more accurate, the required code for this workaround is :

class FMyGameModule : public FDefaultGameModuleImpl
{
	virtual void StartupModule() override
	{
	#if WITH_EDITOR
            FModuleManager::Get().LoadModule("MyModuleEditorName");
        #endif // WITH_EDITOR
       }
}

Ok, so making the workaround the answer:

The problem finally seems to be since UE 4.13, standalone game does not load Editor modules, so it’s not able to load my custom BP node.

So, the workaround is to manually load the Editor module from the Game module if WITH_EDITOR, (thanks Begounet:)

class FMyGameModule : public IModuleInterface
{
	virtual void StartupModule() override
	{
#if WITH_EDITOR
		FModuleManager::Get().LoadModule("MyEditorModule");
#endif // WITH_EDITOR
	}
}

in .uplugin file, change the module LoadingPhase to “PreDefault”