DetourNavMesh is null when reloading streamed world before GC

Hello,

We are currently working on a level loading system that uses sub-world partition levels loaded in a persistent empty world.

The sub-world partition is loaded into the persistent one using the UWorldPartition::RegisterWorldAssetStreaming function and then potentially unloaded by disabling/moving the streaming source.

Our problem appears when trying to unload and reload a sub WP world that uses static baked navdata (with nav chunks). When unloading the level, the navdata is not directly destroyed because of the GC. If we reload the level before the GC pass (that effectively destroys the navdata object), the RecastNavMesh is not re-constructed/serialized and so is not reallocating memory for its DetourNavmesh (in FPImplRecastNavMesh::Serialize => DetourNavMesh = dtAllocNavMesh(); ).

This issue prevent any navigation on the level, even if RecastNavMesh actors are correctly registered in the navigation system.

For now, it seems like we are able to mitigate this issue by forcing the GC after each level loading (hence forcing the destruction of unloaded objects) but this solution is not ideal.

Do you have any ideas for us to resolve this problem ?

[Attachment Removed]

Steps to Reproduce

  • Load a sub world partition in an empty persistent world partition using the UWorldPartition::RegisterWorldAssetStreaming function
  • Unload, and then reload the level by moving the streaming source
  • Observe DetourNavMesh is not reallocated on the NavData if GC was not done on the object
    [Attachment Removed]

This sounds very similar to an issue that happens in WP navmesh using nav data chunks. The current solution/workaround is to enable a CVar for not re-using unloaded levels. The CVar in question is LevelStreaming.ShouldReuseUnloadedButStillAroundLevels 0. This does cause GC to run for all unloaded levels, but we have not reached a full solution for how to handle this case with nav data chunks regathering their associated tiles.

In your case, is the navmesh itself missing or are the NavDataChunkActors being loaded with no tile information? There might be a way to have the data chunk actor retain its copy of the Recast tile data, but this would mean that there is a memory overhead as there would be 2 copies of the tile data.

-James

[Attachment Removed]