Hot-reload Re-instancing prints a warning and sometimes loses instance data 4.13P3

Build Type: 4.13 Preview 3 from Launcher

Build version: Version: 4.13.0-3095848+++UE4+Release-4.13

Detailed description of the issue: After hot-reload, UE4 reinstances objects when default values change. During this process, we get warning messages such as this:

LogUObjectGlobals:Warning: Guid referenced by StaticMeshComponent /Game/Test.Test:PersistentLevel.MyActor_1.staticMesh is already used by StaticMeshComponent /Game/Test.Test:PersistentLevel.MyActor_2.staticMesh, which should never happen in the editor but could happen at runtime with duplicate level loading or PIE

We get this warning for each component of each reinstanced object. Every now and then, we also get an error with a callstack. But it doesn’t cause editor to crash.

LogHotReload: New module detected: UE4Editor-SimpleCar1-3314.dll
LogHotReload: Starting Hot-Reload from IDE
LogHotReload: Re-instancing TriggerShape after hot-reload.
LogStats: FPlatformStackWalk::StackWalkAndDump -  3.064 s
LogOutputDevice:Error: === Handled ensure: ===
LogOutputDevice:Error: Ensure condition failed: bArchetypeReinstanced [File:F:\WORK\UnrealEngine\Engine\Source\Editor\UnrealEd\Private\Kismet2\KismetReinstanceUtilities.cpp] [Line: 1556]
LogOutputDevice:Error: Reinstancing non-actor (/Game/Maps/VehicleExampleMap.VehicleExampleMap:PersistentLevel.Pedestrian10.CapsuleTrigger); failed to resolve archetype object - property values may be lost.
LogOutputDevice:Error: Stack: 
LogOutputDevice:Error: UE4Editor-Core.dll!FWindowsPlatformStackWalk::StackWalkAndDump() [f:\work\unrealengine\engine\source\runtime\core\private\windows\windowsplatformstackwalk.cpp:183]
LogOutputDevice:Error: UE4Editor-Core.dll!FDebug::EnsureFailed() [f:\work\unrealengine\engine\source\runtime\core\private\misc\outputdevice.cpp:297]
LogOutputDevice:Error: UE4Editor-Core.dll!FDebug::OptionallyLogFormattedEnsureMessageReturningFalse() [f:\work\unrealengine\engine\source\runtime\core\private\misc\outputdevice.cpp:432]
LogOutputDevice:Error: UE4Editor-UnrealEd.dll!FBlueprintCompileReinstancer::ReplaceInstancesOfClass_Inner() [f:\work\unrealengine\engine\source\editor\unrealed\private\kismet2\kismetreinstanceutilities.cpp:1556]
LogOutputDevice:Error: UE4Editor-UnrealEd.dll!FBlueprintCompileReinstancer::ReplaceInstancesOfClass() [f:\work\unrealengine\engine\source\editor\unrealed\private\kismet2\kismetreinstanceutilities.cpp:1305]
LogOutputDevice:Error: UE4Editor-UnrealEd.dll!FBlueprintCompileReinstancer::ReinstanceInner() [f:\work\unrealengine\engine\source\editor\unrealed\private\kismet2\kismetreinstanceutilities.cpp:599]
LogOutputDevice:Error: UE4Editor-UnrealEd.dll!FBlueprintCompileReinstancer::ReinstanceObjects() [f:\work\unrealengine\engine\source\editor\unrealed\private\kismet2\kismetreinstanceutilities.cpp:761]
LogOutputDevice:Error: UE4Editor-HotReload.dll!FHotReloadModule::ReinstanceClass() [f:\work\unrealengine\engine\source\developer\hotreload\private\hotreload.cpp:1232]
LogOutputDevice:Error: UE4Editor-HotReload.dll!FHotReloadModule::ReinstanceClasses() [f:\work\unrealengine\engine\source\developer\hotreload\private\hotreload.cpp:1219]
LogOutputDevice:Error: UE4Editor-HotReload.dll!TBaseRawMethodDelegateInstance<0,FHotReloadModule,void __cdecl(void)>::ExecuteIfSafe() [f:\work\unrealengine\engine\source\runtime\core\public\delegates\delegateinstancesimpl.h:638]
LogOutputDevice:Error: UE4Editor-CoreUObject.dll!UClassReplaceHotReloadClasses() [f:\work\unrealengine\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:688]
LogOutputDevice:Error: UE4Editor-CoreUObject.dll!ProcessNewlyLoadedUObjects() [f:\work\unrealengine\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:835]
LogOutputDevice:Error: UE4Editor-CoreUObject.dll!TBaseStaticDelegateInstance<void __cdecl(void)>::ExecuteIfSafe() [f:\work\unrealengine\engine\source\runtime\core\public\delegates\delegateinstancesimpl.h:1017]
LogOutputDevice:Error: UE4Editor-Core.dll!TBaseMulticastDelegate<void>::Broadcast() [f:\work\unrealengine\engine\source\runtime\core\public\delegates\delegatesignatureimpl.inl:921]
LogOutputDevice:Error: UE4Editor-Core.dll!FModuleManager::LoadModuleWithFailureReason() [f:\work\unrealengine\engine\source\runtime\core\private\modules\modulemanager.cpp:461]
LogOutputDevice:Error: UE4Editor-Core.dll!FModuleManager::LoadModule() [f:\work\unrealengine\engine\source\runtime\core\private\modules\modulemanager.cpp:322]
LogOutputDevice:Error: UE4Editor-HotReload.dll!FHotReloadModule::DoHotReloadInternal() [f:\work\unrealengine\engine\source\developer\hotreload\private\hotreload.cpp:828]
LogOutputDevice:Error: UE4Editor-HotReload.dll!FHotReloadModule::DoHotReloadFromIDE() [f:\work\unrealengine\engine\source\developer\hotreload\private\hotreload.cpp:1453]
LogOutputDevice:Error: UE4Editor-HotReload.dll!FHotReloadModule::Tick() [f:\work\unrealengine\engine\source\developer\hotreload\private\hotreload.cpp:1386]
LogOutputDevice:Error: UE4Editor-Core.dll!FTicker::Tick() [f:\work\unrealengine\engine\source\runtime\core\private\containers\ticker.cpp:79]
LogOutputDevice:Error: UE4Editor.exe!FEngineLoop::Tick() [f:\work\unrealengine\engine\source\runtime\launch\private\launchengineloop.cpp:2938]
LogOutputDevice:Error: UE4Editor.exe!GuardedMain() [f:\work\unrealengine\engine\source\runtime\launch\private\launch.cpp:156]
LogOutputDevice:Error: UE4Editor.exe!GuardedMainWrapper() [f:\work\unrealengine\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
LogOutputDevice:Error: UE4Editor.exe!WinMain() [f:\work\unrealengine\engine\source\runtime\launch\private\windows\launchwindows.cpp:202]
LogOutputDevice:Error: UE4Editor.exe!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:264]
LogOutputDevice:Error: KERNEL32.DLL
LogOutputDevice:Error: ntdll.dll
LogOutputDevice:Error: ntdll.dll
LogStats:                SubmitErrorReport -  0.000 s
LogStats:                    SendNewReport -  0.422 s
LogStats:             FDebug::EnsureFailed -  3.489 s
LogUObjectGlobals:Warning: Guid referenced by TriggerShape /Game/Maps/VehicleExampleMap.VehicleExampleMap:PersistentLevel.Pedestrian16.CapsuleTrigger is already used by TriggerShape /Game/Maps/VehicleExampleMap.VehicleExampleMap:PersistentLevel.Pedestrian16.TriggerShape_6, which should never happen in the editor but could happen at runtime with duplicate lev
el loading or PIE
LogUObjectGlobals:Warning: Guid referenced by TriggerShape /Game/Maps/VehicleExampleMap.VehicleExampleMap:PersistentLevel.Pedestrian20.CapsuleTrigger is already used by TriggerShape /Game/Maps/VehicleExampleMap.VehicleExampleMap:PersistentLevel.Pedestrian20.TriggerShape_11, which should never happen in the editor but could happen at runtime with duplicate le
vel loading or PIE
LogHotReload: Re-instancing Pedestrian after hot-reload.
LogUObjectGlobals:Warning: Guid referenced by ArrowComponent /Game/Maps/VehicleExampleMap.VehicleExampleMap:PersistentLevel.Pedestrian16.arrow is already used by ArrowComponent /Game/Maps/VehicleExampleMap.VehicleExampleMap:PersistentLevel.Pedestrian_7.arrow, which should never happen in the editor but could happen at runtime with duplicate level loading or 
PIE
LogUObjectGlobals:Warning: Guid referenced by SkeletalMeshComponent /Game/Maps/VehicleExampleMap.VehicleExampleMap:PersistentLevel.Pedestrian16.SkelMesh is already used by SkeletalMeshComponent /Game/Maps/VehicleExampleMap.VehicleExampleMap:PersistentLevel.Pedestrian_7.SkelMesh, which should never happen in the editor but could happen at runtime with duplica
te level loading or PIE
LogUObjectGlobals:Warning: Guid referenced by PedestrianMovementComponent /Game/Maps/VehicleExampleMap.VehicleExampleMap:PersistentLevel.Pedestrian16.PedestrianMovementComp is already used by PedestrianMovementComponent /Game/Maps/VehicleExampleMap.VehicleExampleMap:PersistentLevel.Pedestrian_7.PedestrianMovementComp, which should never happen in the editor 
but could happen at runtime with duplicate level loading or PIE
LogUObjectGlobals:Warning: Guid referenced by ArrowComponent /Game/Maps/VehicleExampleMap.VehicleExampleMap:PersistentLevel.Pedestrian20.arrow is already used by ArrowComponent /Game/Maps/VehicleExampleMap.VehicleExampleMap:PersistentLevel.Pedestrian_12.arrow, which should never happen in the editor but could happen at runtime with duplicate level loading or
 PIE
LogUObjectGlobals:Warning: Guid referenced by SkeletalMeshComponent /Game/Maps/VehicleExampleMap.VehicleExampleMap:PersistentLevel.Pedestrian20.SkelMesh is already used by SkeletalMeshComponent /Game/Maps/VehicleExampleMap.VehicleExampleMap:PersistentLevel.Pedestrian_12.SkelMesh, which should never happen in the editor but could happen at runtime with duplic
ate level loading or PIE
LogUObjectGlobals:Warning: Guid referenced by PedestrianMovementComponent /Game/Maps/VehicleExampleMap.VehicleExampleMap:PersistentLevel.Pedestrian20.PedestrianMovementComp is already used by PedestrianMovementComponent /Game/Maps/VehicleExampleMap.VehicleExampleMap:PersistentLevel.Pedestrian_12.PedestrianMovementComp, which should never happen in the editor
 but could happen at runtime with duplicate level loading or PIE
LogContentBrowser: Native class hierarchy updated for 'SimpleCar1' in 0.0015 seconds. Added 12 classes and 3 folders.
Display: HotReload successful (2 functions remapped  0 scriptstructs remapped)
LogContentBrowser: Native class hierarchy populated in 0.0096 seconds. Added 2168 classes and 436 folders.
Display: HotReload took  4.8s.

However, there is no telling when this occurs, and when it causes data loss. It seems to be happening randomly. Sometimes we add a whitespace in a completely unrelated file and UE4 decides to re-instance our actor class and causes data loss again.

Example code:

UCLASS()
class HOTRELOADTEST_API AMyActor : public AActor
{
	GENERATED_BODY()
	
public:	
	AMyActor();

	UPROPERTY(Category = Rendering, VisibleDefaultsOnly, BlueprintReadOnly)
	class UStaticMeshComponent* StaticMesh;

	UPROPERTY(EditAnywhere)
	int asd = 0;
};

AMyActor::AMyActor()
{
	StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("staticMesh"));
	RootComponent = StaticMesh;

	static ConstructorHelpers::FObjectFinder<UStaticMesh> assetMesh(
		TEXT("StaticMesh'/Engine/BasicShapes/Cube.Cube'"));
	if (assetMesh.Succeeded()) {
		StaticMesh->SetStaticMesh(assetMesh.Object);
	}
}

When this actor is placed in the world. Changing the default value of asd member variable causes re-instancing and generated the warning message. However, I couldn’t get crash to occur in this smaller example.

System Specs: Windows 10, 16 GB RAM

I managed to reproduce the issue in 4.12.5 as well.

Hey DenizPiri-

Where are you seeing the warning messages appear? After creating a class using the code provided and preforming multiple hot reloads I did not see any warnings in the editor log window or the output from Visual Studio.

Hi ,

Warning messages appear in output log. Warning message (and sometimes the crash) occur only when UE4 reinstances the object. To do that you can change the default value of the ‘asd’ variable in the header. If you like, i can try packaging the project I have, or making a video showcasing the error.

A video of what you’re seeing along with a sample project where the issue is occurring for your would help me investigate the issue. If you zip the project you can attach it to a comment.

Here you go: https://youtu.be/4KCVWscs2X0
I started a fully blank C++ project. It occured with the first hot reload. Strangely, it didn’t occur in the next 2 hot reloads. But as I have noted before, in our main project on 4.13, it occurs almost every time, but every time it occurs for different objects. And every now and then we get that internal crash and component data on some of the instances gets reset, but not to defaults we specified in our constructor, instead the defaults of the component’s own constructor. Then UE4 saves these modifications, which makes hotreload very dangerous for us to use.

Thumbs up, having same issue here.

In our case we have objects with UPROPERTY pointers to other similar objects (sort of tile map with linked tiles), all objects are derived from C++ classes, not BP. If we set tiles links then recompile, we get warnings about duplicate GUIDs and all links become empty and it takes some time to link the tiles. As I understand it tries to instantiate new objects from changed classes before removing old ones. Same happens with components - Timeline, StaticMesh, even SceneComponent. Could be great to have it solved. Thanks.

Great to know that we are not the only ones having experiencing this issue ! :smiley:
Kind of sucks being forced not to use hotreload because of this issue.

Hey DenizPiri-

I was able to get the warning message to appear for me however I did not have an instance of the callstack you mentioned occur. This has been reported and can be viewed here: Unreal Engine Issues and Bug Tracker (UE-35870)

As a note, the warning message appears to only occur for the first hot reload after adding the class instance to the viewport, preforming a second hot reload did not give the message for any existing instances of the class.

Cheers

I’m also experiencing this with a project in 4.12.5 and was then also able to reproduce it with steps provided in Unreal Engine Issues and Bug Tracker (UE-35870) Since DenizPiri also made a video, issue tracker regression, “Yes, this warning message does not appear in 4.12.5 after hot reload.” should probably be updated.

Still experiencing this in 4.15.1!

Hey ndelchen-

The bug report mentioned in the answer is still unresolved. I have added a note to indicate that this is still affecting people.

I have a similar or maybe the same problem. When I use Windows->Developertools ->Modules and reload my custom plugin I get a couple of error messages and a crash when hitting the play button.
Everything works fine when you compile and restart the editor.

The complete log is attached as a txt file.

Below is the code I use to instantiate the components.
The actor is a BlueprintType with preinstantiated camera components, so all you have to do is fill in some meshes and settings. The component that seems to be messed up is the CameraComponentOrbit. It is inherited from UCameraComponent to implement custom logic.

After the first reload I can still hit the play button but the actor settings are messed up and the object instance shows undefined behaviour.

After the second reload the editor crashes on play.

UCLASS(Abstract, ClassGroup = "TG|Vehicle")
class TGVEHICLE_API UTGVehicleCameraComponent : public UCameraComponent
{
	GENERATED_UCLASS_BODY()

protected:


[UCLASS(ClassGroup = "TG|Vehicle")
class TGVEHICLE_API UTGVehicleCameraComponentCockpit : public UTGVehicleCameraComponent
{
	GENERATED_UCLASS_BODY()

};][1]


Mesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("VehicleMeshComponent"));
Mesh->SetSkeletalMesh(CarMesh.Object);
Mesh->SetCollisionProfileName(UCollisionProfile::Vehicle_ProfileName);
Mesh->BodyInstance.bSimulatePhysics = true;
Mesh->BodyInstance.bNotifyRigidBodyCollision = true;
Mesh->BodyInstance.bUseCCD = true;
Mesh->bBlendPhysics = true;
Mesh->bGenerateOverlapEvents = true;
Mesh->SetCanEverAffectNavigation(false);
RootComponent = Mesh;

CameraCockpit = CreateDefaultSubobject<UTGVehicleCameraComponentCockpit>(TEXT("VehicleCameraComponentCockpit"));
CameraCockpit->AttachToComponent(RootComponent, FAttachmentTransformRules(EAttachmentRule::KeepRelative, false));

CameraOrbit = CreateDefaultSubobject<UTGVehicleCameraComponentOrbit>(TEXT("VehicleCameraComponentOrbit"));
CameraOrbit->AttachToComponent(RootComponent, FAttachmentTransformRules(EAttachmentRule::KeepRelative, false));

Error message after 1. reload

LogStats: FPlatformStackWalk::StackWalkAndDump -  0.119 s
LogOutputDevice:Error: === Handled ensure: ===
LogOutputDevice:Error: Ensure condition failed: bArchetypeReinstanced [File:D:\Build\++UE4+Release-4.15+Compile\Sync\Engine\Source\Editor\UnrealEd\Private\Kismet2\KismetReinstanceUtilities.cpp] [Line: 1752]
LogOutputDevice:Error: Reinstancing non-actor (/Script/TGVehicle.Default__TGVehicleTank:VehicleCameraComponentOrbit); failed to resolve archetype object - property values may be lost.

Error message after second reload:

LogOutputDevice:Error: === Handled ensure: ===
LogOutputDevice:Error: Ensure condition failed: GIsTransacting [File:D:\Build\++UE4+Release-4.15+Compile\Sync\Engine\Source\Runtime\Engine\Private\Components\SceneComponent.cpp] [Line: 1026]
LogOutputDevice:Error: Stack: 


LogSceneComponent:Error: Component 'TGVehicleCameraComponentOrbit /Game/VehicleAdvCPP/Maps/VehicleAdvExampleMap.VehicleAdvExampleMap:PersistentLevel.vvvvvv2.TGVehicleCameraComponentOrbit_0' has 'DrawFrustumComponent /Game/VehicleAdvCPP/Maps/VehicleAdvExampleMap.VehicleAdvExampleMap:PersistentLevel.vvvvvv2.DrawFrustumComponent_9' in its AttachChildren array, 
however, 'DrawFrustumComponent /Game/VehicleAdvCPP/Maps/VehicleAdvExampleMap.VehicleAdvExampleMap:PersistentLevel.vvvvvv2.DrawFrustumComponent_9' believes it is attached to 'TGVehicleCameraComponentOrbit /Game/VehicleAdvCPP/Maps/VehicleAdvExampleMap.VehicleAdvExampleMap:PersistentLevel.vvvvvv2.VehicleCameraComponentOrbit'
LogSceneComponent:Error: Component 'TGVehicleCameraComponentOrbit /Game/VehicleAdvCPP/Maps/VehicleAdvExampleMap.VehicleAdvExampleMap:PersistentLevel.vvvvvv2.TGVehicleCameraComponentOrbit_0' has 'StaticMeshComponent /Game/VehicleAdvCPP/Maps/VehicleAdvExampleMap.VehicleAdvExampleMap:PersistentLevel.vvvvvv2.StaticMeshComponent_9' in its AttachChildren array, ho
wever, 'StaticMeshComponent /Game/VehicleAdvCPP/Maps/VehicleAdvExampleMap.VehicleAdvExampleMap:PersistentLevel.vvvvvv2.StaticMeshComponent_9' believes it is attached to 'TGVehicleCameraComponentOrbit /Game/VehicleAdvCPP/Maps/VehicleAdvExampleMap.VehicleAdvExampleMap:PersistentLevel.vvvvvv2.VehicleCameraComponentOrbit'
LogSceneComponent:Error: Component 'TGVehicleCameraComponentOrbit /Game/VehicleAdvCPP/Maps/VehicleAdvExampleMap.VehicleAdvExampleMap:PersistentLevel.vvvvvv1.TGVehicleCameraComponentOrbit_1' has 'DrawFrustumComponent /Game/VehicleAdvCPP/Maps/VehicleAdvExampleMap.VehicleAdvExampleMap:PersistentLevel.vvvvvv1.DrawFrustumComponent_7' in its AttachChildren array, 
however, 'DrawFrustumComponent /Game/VehicleAdvCPP/Maps/VehicleAdvExampleMap.VehicleAdvExampleMap:PersistentLevel.vvvvvv1.DrawFrustumComponent_7' believes it is attached to 'TGVehicleCameraComponentOrbit /Game/VehicleAdvCPP/Maps/VehicleAdvExampleMap.VehicleAdvExampleMap:PersistentLevel.vvvvvv1.VehicleCameraComponentOrbit'
LogSceneComponent:Error: Component 'TGVehicleCameraComponentOrbit /Game/VehicleAdvCPP/Maps/VehicleAdvExampleMap.VehicleAdvExampleMap:PersistentLevel.vvvvvv1.TGVehicleCameraComponentOrbit_1' has 'StaticMeshComponent /Game/VehicleAdvCPP/Maps/VehicleAdvExampleMap.VehicleAdvExampleMap:PersistentLevel.vvvvvv1.StaticMeshComponent_7' in its AttachChildren array, ho
wever, 'StaticMeshComponent /Game/VehicleAdvCPP/Maps/VehicleAdvExampleMap.VehicleAdvExampleMap:PersistentLevel.vvvvvv1.StaticMeshComponent_7' believes it is attached to 'TGVehicleCameraComponentOrbit /Game/VehicleAdvCPP/Maps/VehicleAdvExampleMap.VehicleAdvExampleMap:PersistentLevel.vvvvvv1.VehicleCameraComponentOrbit'

Hey EddyTheTank-

I copied the code you provided into a new project and preformed a hot reload but did not get the error messages you mentioned. Are you seeing the messages in the editor output log? If you’re able to reproduce the behavior in a small sample project, could you provide a copy of that project? That could help with the currently open ticket in our system for this issue: Unreal Engine Issues and Bug Tracker (UE-35870)

How can I send you a copy of the project? I rather don’t want to post a public link.

How can I send you a copy of the project? I rather don’t want to post a public link.

One thing I would like to check out before I send you the code is to delete the intermediate folders.

If you can post the project to google drive / dropbox, you can send me a PM on the forums with the link to download the project. https://forums.unrealengine.com/private.php?do=newpm&u=14493

I have sent you the project as PM.

I have tried a few more things and deleted all saved, build, and intermediate folders. Now I can recompile the plugin from Developertools->Modules without warnings/errors. After hot reload however the pawn setup seems to get corrupted and the vehicle jumps around.

I have noticed different behaviours when restarting the editor and recompiling the plugin again. Looks like some internal variables are filled with data from random memory during hot reload.

TODO:
I haven’t tested to unlink all the blueprints yet, maybe the blueprints get corrupted.(some apply forces).

NOTE:
1.) The project was generated for VS2015 but is use VS2017 for editing due to its better intellisense.
2.) When recompiling modules it seems to use the build target “Development” however when compiling inside VS2017 it uses “Development Editor” by default

I hope that helps.

If I find out more I’ll post it here

Can you explain what you mean by the pawn setup being corrupted? I opened the project and preformed a hot reload, but I did not notice any difference in behavior during play. Please elaborate on what differences you’re referring to after the hot reload.

1.) Load the editor
2.) modify a file(insert a space or change a string in the TGVehicle Plugin
3.) use the Editor->DevTools->Modules window to recompile the TGVehicle Plugin

4.) Now when you hit the play button the vehicle wil show undefined behaviour and flies wildly through the air. However this behaviour is not consistent and seems to change when you clean up the project (intermediate folders,…) and recompile everything.

At first it did create with the errors mentioned above.