Hot reload fails until you alter and then save a class constructor

I am having an issue that sometimes when I change something in a header file, hot reload fails until I open a cpp file (any cpp file) and simply add and remove a space in the cpp file, then save. Then, when I recompile, hot reload loads correctly.

This is the print out:

Recompiling D...
Launching UnrealBuildTool... [D:/Program Files/Epic Games/Epic          Games/4.11/Engine/Binaries/DotNET/UnrealBuildTool.exe D -ModuleWithSuffix D 8449 Win64 Development -editorrecompile -canskiplink "D:/Program Files/Epic Games/UnrealProjects/D/D.uproject"  -2015]
Warning: Starting HotReload took  0.0s.
CompilerResultsLog: New page: Compilation - May 7, 2016, 10:08:48 AM
CompilerResultsLog: Info Compiling game modules for hot reload
CompilerResultsLog: Info ERROR: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
CompilerResultsLog: Info Parameter name: startIndex
CompilerResultsLog: Info    at System.String.LastIndexOf(Char value, Int32 startIndex, Int32 count)
CompilerResultsLog: Info    at UnrealBuildTool.UnrealBuildTool.PatchActionHistoryForHotReloadAssembling(List`1 OnlyModules)
CompilerResultsLog: Info    at UnrealBuildTool.UnrealBuildTool.RunUBT(String[] Arguments, FileReference ProjectFile)
LogMainFrame: MainFrame: Module compiling took 0.581 seconds
Warning: HotReload failed, recompile failed

Hello Vawx,

If you close the editor after changing the header file and then compile rather than attempting to hot reload, do the same results occur? Also, when you’re making these edits to your header file, what kind of edits are they? Nothing I can think of justifies this behavior but the first step of reporting something like this is to reproduce it.

Hey Mathew,

Closing the editor and compiling the game project from visual studio works fine (though as soon as I open the editor again and as long as the last file saved was a .h file, hot reload still fails to load until I save a .cpp file). It’s only when I use the compile button from within the editor that I get the “Warning: HotReload failed, recompile failed” error, until I save a .cpp file. Then the compile button works, as Hotreload is loaded and compiles.

Also, the changes in the header file can literally just be adding a space to the file somewhere and saving it. None of the changes are strange or would cause compile issues on their own.

You mention using the compile button inside of the editor, which makes me curious. What happens if you attempt to build via Visual Studio while the editor is open? This should still trigger a hot reload but could have different results.

Also, I should’ve asked this previously, but have you used previous versions of the editor prior to 4.11? If so, did you have the same issues there? What version of Visual Studio are you using? In particular, which update? This can be found inside of Visual Studio under Help > About.

So saving a header file and then compiling from visual studio, with the editor running, works fine. Even when I go back to the editor and compile, hot reload seems to load and run fine.

Here is the out put from visual studio for compiling with a header file change:

1>------ Build started: Project: D, Configuration: Development_Editor x64 ------
1>  Creating makefile for hot reloading DEditor (modules to compile have changed)
1>  Compiling game modules for hot reload
1>  Parsing headers for DEditor
1>    Running UnrealHeaderTool "D:\Program Files\Epic Games\UnrealProjects\D\D.uproject" "D:\Program Files\Epic Games\UnrealProjects\D\Intermediate\Build\Win64\DEditor\Development\UnrealHeaderTool.manifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
1>  Reflection code generated for DEditor in 2.9962955 seconds
1>  Performing 4 actions (4 in parallel)
1>  D.generated.cpp
1>  DWeaponPistols.cpp
1>  DWeaponManager.cpp
1>  [4/4] Link UE4Editor-D.d-9174ll
1>     Creating library D:\Program Files\Epic Games\UnrealProjects\D\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-D.lib and object D:\Program Files\Epic Games\UnrealProjects\D\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-D.exp
1>  -------- End Detailed Actions Stats -----------------------------------------------------------
1>  Total build time: 6.48 seconds
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

I have used UE4 since being a part of the “rocket” beta. This is the first instance this has happened.

Here is my visual studio version:

Steps:

  1. Visual studio and UE4 editor running.
  2. Edit .h file with a space and save file.
  3. Use compile button in UE4 editor, watch hot reload fail.
  4. Build game project in Visual Studio, watch compile succeed.
  5. Use compile button in UE4 editor, watch hot reload work and see “Compile Complete!”

Started as a blank cpp project but it has a fair few custom classes added. It doesn’t matter which .h file, though I am only editing the ones for my project, as in I’m not editing ACharacter, APlayerController, AHUD, AActor, etc…

Unfortunately it won’t reproduce for me. To make sure, is this in a blank project? Is the .h that is being edited part of a custom class that was added to the project? I may be assuming some things here that are leading to different results.

Trying on a new blank c++ project doesn’t seem to have the same issue, though I haven’t added much code. Out of the box, the blank project doesn’t have the same issue, though.

I am using the launcher build as I am honestly unsure of the difference of using GitHub source vs the launcher as I read a while back that the source is distributed through the launcher now; though that could be wrong.

I should’ve asked before, but have you tried this in a completely fresh blank C++ project? Also, is your build of 4.11 from the Epic Games Launcher or downloaded from Github? I’m trying to gather as much information as I can, as I haven’t had this happen on my side as of yet.

That would explain why it hasn’t happened for me then, as I’ve been using blank projects except for adding some blank actor classes and the sort.

As for your second comment, some of the source files are distributed with the engine, but it is lacking files for compiling the engine to save space while also having all of those source filess set to Read-Only. The source downloaded from Github is compiled locally and allows for editing of the source code and selective compiling, as not everything needs to be compiled. This also allows people to merge in changes that haven’t been added to the release version yet if they need it.

It’s not the biggest deal, just annoying.

I can only guess that something I’ve added to the code or some mishap with saving the visual studio project causes hot reload to hiccup.

This line being the clue:

 CompilerResultsLog: Info ERROR: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.

If you’re able to find out what is causing this particular problem in your project, I would be happy to take a look and see if we can determine if it is a problem or a logic error. In the meantime, I’ll be marking this as resolved for tracking purposes. Please feel free to comment back with any information you’re able to find.