Navmesh doesnt appear on level the first time it's loaded during automated test


in my company I’m preparing some automated tests. One of the things I’m currently trying to check is if a follower NPC actually follows the player. I have set up a super simple scene for it. The issue is that the first time this level is loaded in PIE session by the automated test framework, navmesh is either fully or partially missing. Only after the test ends and game is closed does “Building navmesh” appear and then navmesh will be present. Because of this issue the test doesn’t pass even though there are no actual issues with it. This happens on each editor session (so if editor is restarted, even without any changes, issue will be back).

Here is a screenshot of the level with some stuff that could be recognized/linked to the project hidden. You can also see the recastnavmesh-default settings there:

There are some wierd parts to this issue. When the tests are running on Jenkins slave, only the first test on this map fails. Two other tests which also heavily rely on navigation finish successfully. Another wierd part is that for a very long time I couldn’t reproduce this bug locally, on my PC, but some people (and the slave) could. After that I started fiddling with navmesh settings and at some random point I could reproduce it locally. Then further changes made the issue go away for me again, thinking it’s fixed but the slave still had it and tests were failing. Also, what was noticed, is that if the level itself is opened in editor before running the tests, issue doesn’t occur.

Some of the things we’ve tried, neither helped:

  • changing from 1 navmesh bounds to 3 smaller ones
  • changing from 3 back to 1, using brush settings instead of scale to set size of the volume (yeah, I know, it was dumb to use scale in the first place)
  • rebuilding the level completely
  • removing the climbable and bridge actors (they spawn nav links on begin play)
  • changing RecastNavMesh-Default settings: using ForceRebuildOnLoad, changing Runtime Generation to all of its settings, unticking Autodestroy When No Navigation and multiple combinations of those settings
  • Building whole map and commiting the _BuiltData file (it was commited before anyway).

At this point I’m at complete loss. I’ve never seen an issue like this and don’t know how to make it go away. Does anyone have any ideas how to fix or at least reasonably work around? Here are two more screenshots, one from the first test run, one from subsequent run in same editor session.