Hot reload fails: "This is likely a stale module that must be recompiled."

Hey Gigantoad-

Sorry for the delayed response. Is this issue still a problem for you in the latest version of the engine? Please let us know if you are still having any issues with using hot reload.

Cheers

Hi ! Yes it’s still happenng sadly. I get around it by hitting Compile in the editor instead. Here’s the current message that shows up in the editor when trying to compile in Visual Studio:

LogModuleManager:Warning: Found module file C:/Users/Patrick/Documents/Unreal Projects/Ikosphere/Binaries/Win64/UE4Editor-Ikosphere-7387.dll (API version -1), but it was incompatible with the current engine API version (0). This is likely a stale module that must be recompiled.
Warning: HotReload failed, reload failed /Script/Ikosphere.

Hey Gigantoad-

When you compile in visual studio does it through out any errors? Do the actions in code show after attempting to compile. What I mean is if you Create a class and mark a function of that class as UFUNCTION(BlueprintCallable), are you able to see the function inside a blueprint graph for the class?

No errors in Visual Studio whatsoever. That other thing I can’t try at the moment but to be honest I don’t see how that could work when hot reload fails on even the simplest stuff like just changing one line of code in the pawn.

Hi Gigantoad,

I tried to reproduce this again using 4.7.3 and was still unable to see the results that you described. Let me outline what I am doing and if you could point out where you are doing something different, that would be great.

  • Create a new code project using the Top Down template.

  • Right-click on the project in the Solution Explorer in Visual Studio and click Build.

  • After the build completes in Visual Studio, open the project in the Editor.

  • Open the Output Log window in the Editor.

  • Add a new code class derived from Actor named MyActor.

  • After the new class is added and Visual Studio reloads, open the MyActor.h file and add the following line of code: int32 a1, a2, a3, a4;

  • Right-click on the project in the Solution Explorer in Visual Studio and click Build to trigger a Hot Reload.

  • The Output Log window in the Editor indicates the Hot Reload was successful.

  • Add the following code to the MyActor.h file:

     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = TestCat)
     float TestMe;
    
  • Right-click on the project in the Solution Explorer in Visual Studio and click Build to trigger a Hot Reload.

  • The Output Log window in the Editor indicates the Hot Reload was successful.

  • Create a new code class derived from Pawn named MyPawn.

  • After the new class is added and Visual Studio reloads, open the MyPawn.h file and add the following line of code: int32 m1, m2, m3, m4;

  • Right-click on the project in the Solution Explorer in Visual Studio and click Build to trigger a Hot Reload.

  • The Output Log window in the Editor indicates the Hot Reload was successful.

  • Add the following code to the MyPawn.h file:

     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = MyTestCat)
     float TestMe2;
    
  • Right-click on the project in the Solution Explorer in Visual Studio and click Build to trigger a Hot Reload.

  • The Output Log window in the Editor indicates the Hot Reload was successful.

What are you doing differently?

Hi

I hadn’t actually tried in the TopDown test project, only in my own game with the custom editor. I did just upgrade TopDown to 4.73 (normal binary version from launcher) and found a behavior even more weird. You can try and see if you can repro it with these simple steps:

  • In TopDownPlayerController.cpp comment out the if statement in the last function

    //if (Character)
    //{
    // Character->Jump();
    //}

  • Build and see if the editor hot reloads (it does for me a few times)

  • Remove comments, build, check again, repeat until hot reload breaks

No error in Visual Studio as ever:

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Build Summary
-------------
00:07.235 - Success - DebugGame_Editor x64 - Intermediate\ProjectFiles\TopDown.vcxproj

Total build time: 00:07.235

========== Build: 1 succeeded or up-to-date, 0 failed, 1 skipped, Completed at 19.03.2015 00:51:42 ==========

But this message in the editor:

LogModuleManager:Warning: Found module file D:/Unreal Projects/TopDown/Binaries/Win64/UE4Editor-TopDown-5561-Win64-DebugGame.dll (API version -1), but it was incompatible with the current engine API version (2455222). This is likely a stale module that must be recompiled.
Warning: HotReload failed, reload failed /Sc

I spent some time this morning with a code project from the binary 4.7.3 version, commenting and uncommenting several lines of code and building and rebuilding the project in Visual Studio in order to trigger a Hot Reload in the Editor. I was unable to get the results that you are seeing. Every time I built the project, these were the results displayed in the Output Log:

LogHotReload: New module detected: UE4Editor-TestHotReload3-6889-Win64-DebugGame.dll
LogHotReload: Starting Hot-Reload from IDE
LogContentBrowser: Native class hierarchy updated for 'TestHotReload3' in 0.0064 seconds. Added 3 classes and 2 folders.
Warning: HotReload successful (0 functions remapped  0 scriptstructs remapped)
LogContentBrowser: Native class hierarchy populated in 0.0137 seconds. Added 1700 classes and 265 folders.

The only differences were the time taken and the number in the module name. Which does make me curious about something. How many files do you have in the Project\Binaries\Win64 folder?

These 4 files.

UE4Editor-TopDown.dll
UE4Editor-TopDown.pdb
UE4Editor-TopDown-Win64-DebugGame.dll
UE4Editor-TopDown-Win64-DebugGame.pdb

That was after doing a build in Visual Studio with the Editor closed (no Hot reload), correct? Every Hot Reload should add a new .dll and .pdb file to this folder. Are you always able to get a few successful hot reloads before they start failing? If so, does the number of successful hot reloads vary?

When you asked I’m pretty sure both were closed and I just checked what’s in the folder. I just tried again after compiling with the editor open, hot reload instantly failed this time and now there are 2 more files.

  • UE4Editor-TopDown-6930-Win64-DebugGame.dll
  • UE4Editor-TopDown-6930-Win64-DebugGame.pdb

And this message in the editor output log:

LogModuleManager:Warning: Found module file D:/Unreal Projects/TopDown/Binaries/Win64/UE4Editor-TopDown-6930-Win64-DebugGame.dll (API version -1), but it was incompatible with the current engine API version (2455222). This is likely a stale module that must be recompiled.
Warning: HotReload failed, reload failed /Script/TopDown.

Hi Gigantoad, the error is very strange and it could mean a few different things. We can’t reproduce it locally but I wonder if you could debug it on your side and get back to us with your findings. I was thinking you could maybe launch the editor in VS (debug config) and after the editor with your project is open, launch another instance of Visual Studio where you’ll be making code changes and compiling them. But before you hit compile in VS, add a breakpoint inside FWindowsPlatformProcess::GetDllApiVersion function. I’m curious at what point it fails and exits.

This could either be a problem with our build system not embedding the API version inside of the DLL binary or for some reason it can’t open the module before loading it and it can’t check its version (maybe a virus scanner is preventing access, not sure). In the latter case it would also be worth to add ::GetLastError() checks after each call to windows API (maybe log them?).

Thanks for your patience.

Hi Robert, I did as you said but everything workes fine, no more hot reload errors at all in the new new “Debug Editor” configuration!

So I went back to the TopDown project with the binary editor and still the same hot reload error. After changing from “DebugGame” (which in hindsight I’m not even sure why it was set to that in the first place) to “Development Editor” or “Debug Game Editor”, hot reload seems to work again.

So after a lot more testing, my fix for now seems to be to close the editor, hit F5 in Visual Studio, let the Editor load, then in VS do Debug > Detach all. That way I seem to have a 100% certainty that the build configuration of the open editor matches that of Visual Studio. Of course I’m still not entirely sure about what’s going on behind the curtain there, and the fact that even after a year of using UE4 I’m still not entirely familiar with all these different build configurations doesn’t help either.

When I do change the build configuration to, say, “Development” while the editor is open, I do not get hot reload at all which is the behavior I’d expect. On the other hand, if I switch from “Development Editor” to "DebugGame Editor* while the editor is open, it still hot reloads fine.

So my best guess is that there exists an obscure bug where the editor can somehow be opened with a build configuration that isn’t compatible with the one chosen in VS when compiling, yet hot reload still thinks it should work but fails?

Oh by the way, that may have sounded like I keep changing build configurations all the time, but I don’t. In my own game I had in on “Development Editor” since forever and never changed a thing about that. Still hot reload eventually broke. In light of that, my theory above doesn’t seem to make much sense.

Hi Gigantoad,

DebugGame Editor is a special “mixed” configuration where the engine is using Development binaries and the game Debug binaries. It used to be a completely separate config with its own set of binaries but it has changed to save space.

I’m going to be looking at various Hot Reload improvements and fixes for 4.8 so hopefully the workflow is going to improve.

I am sorry to resurrect such an old issue but this is definitely still happening in 4.17.

The issue triggers when using the same “DebugGame” build as the original poster:

  1. Set the build configuration to “DebugGame Editor”.
  2. Compile and Build the Editor (F5).
  3. Once the Editor is running, Detach All.
  4. Modify game code (not engine code).
  5. Compile.
  6. Notice a new hot reload dll is built: UE4Editor-Editor-7466-Win64-DebugGame.dll
  7. And in the Editor, notice it fails to hot-reload.

with the following output:

LogHotReload: New module detected: UE4Editor-PROJECT-3328-Win64-DebugGame.dll
LogHotReload: Starting Hot-Reload from IDE
LogModuleManager: Warning: Found module file PATH/TO/UnrealProject/Binaries/Win64/UE4Editor-PROJECT-3328-Win64-DebugGame.dll (API version -1), but it was incompatible with the current engine API version (0). This is likely a stale module that must be recompiled.
Warning: HotReload failed, reload failed /Script/PROJECT.
LogContentBrowser: Native class hierarchy populated in 0.1156 seconds. Added 3010 classes and 600 folders.
Display: HotReload took  0.7s.

It looks like anything built under “DebugGame Editor” will fail to hot-reload.

Update:

Note that tracing FPlatformProcess::GetDllApiVersion shows that LoadLibraryEx fails to load the module, which explains the “-1” API version returned.

Hi ,

Sorry for not getting back to you sooner on this. Is this something that you are still having trouble with? I tried following the steps that you outlined in both 4.17.2 and 4.18.3, and the hot reload completed successfully for me in both cases. If you are still having trouble with this, we have a new method for reporting Engine bugs. Please visit our Report a Bug page and fill out the form with as much information as you have available.