In unreal engine 5.1 there was a latent automated test set up in the project designed to run each time the project was built, essentially a unit test. It works perfectly in 5.1 and follows the small pages of the documentation related to automated tests.
It uses the LatentIt()
function with a lamda callback. The lambda broadcast’s it’s completion using the FDoneDelegate::Execute()
function and it also receives an FDoneDelegate
object as a parameter.
After migrating to 5.3, several issues were fixed except that the unit tests always timed out.
By placing a breakpoint in the FDoneDelegate::Execute()
function, I have found that there is a class that periodically checks for the completion of the test called FUntilDoneLatentCommand
and there was a member function that sets the test as done:
void Done() { if (bIsRunning) { bDone = true; } }
The thing that catch my attention was that bIsRunning was never true, and the test was never marked with bDone = true, eventually timing out.
So I checked the 5.1 source code for the same class and indeed they differ:
5.3 (This is an engine header file, I’ve only added comments. Censored part of the comments is nothing relevant)
5.1
In 5.1 there is no check in order to set the test as “done”.
In 5.3, the Predicate
variable runs the Done function, but bIsRunning is false (it’s only set to true after the line where Done()
gets called) so it won’t set the test as done.
Then the Update()
function gets called again, but bIsRunning
is true, so it won’t enter the scope of the if() statement
, where the Done()
function is called, so it won’t ever be able to set the test as Done, eventually timing out.
Checklist:
bDone
is a private variable only accessed in these two functions.Done()
function is a private function only called by update.- Verified the change notes and nothing contained information about changes in the Lantent Automated Tests.
- Searched google for people with similar problems, nothing was found (I guess automated tests are not used much)
- Make a dummy test where the lambda instantly broadcasts the
FDoneDelegate
(didn’t work)
I’m guessing this is an engine bug, let me know if I am missing anything or if you have more information about this.