40 minutes to "load" a static mesh (from open world sample) - FindBestPacking / PackCharts()

I was trying to use one of the assets from the open world sample (HillTree02), and it took forever to load it.
When debugging it, I found out why it’s so slow. Not sure why it was programmed in such way though; Would love to hear why,
I could possibly try and fix that.

Stack Trace:

> [Inline Frame] UE4Editor-MeshUtilitiesCommon.dll!FAllocator2D::Test(FAllocator2D::FRect) Line 150 C++
UE4Editor-MeshUtilitiesCommon.dll!FAllocator2D::FindBitByBit(FAllocator2D::FRect & Rect, const FAllocator2D & Other) Line 94 C++
UE4Editor-MeshUtilitiesCommon.dll!FLayoutUV::PackCharts() Line 843 C++
UE4Editor-MeshUtilitiesCommon.dll!FLayoutUV::FindBestPacking() Line 604 C++
UE4Editor-MeshDescriptionOperations.dll!FMeshDescriptionOperations::CreateLightMapUVLayout(FMeshDescription & MeshDescription, int SrcLightmapIndex, int DstLightmapIndex, int MinLightmapResolution, ELightmapUVVersion LightmapUVVersion, const FOverlappingCorners & OverlappingCorners) Line 1191 C++
UE4Editor-MeshBuilder.dll!FMeshDescriptionHelper::GetRenderMeshDescription(UObject * Owner, const FMeshDescription & InOriginalMeshDescription, FMeshDescription & OutRenderMeshDescription) Line 138 C++
UE4Editor-MeshBuilder.dll!FStaticMeshBuilder::Build(FStaticMeshRenderData & StaticMeshRenderData, UStaticMesh * StaticMesh, const FStaticMeshLODGroup & LODGroup) Line 120 C++
UE4Editor-MeshBuilder.dll!FMeshBuilderModule::BuildMesh(FStaticMeshRenderData & OutRenderData, UObject * Mesh, const FStaticMeshLODGroup & LODGroup) Line 41 C++
UE4Editor-Engine.dll!FStaticMeshRenderData::Cache(UStaticMesh * Owner, const FStaticMeshLODSettings & LODSettings) Line 1643 C++
UE4Editor-Engine.dll!UStaticMesh::CacheDerivedData() Line 3270 C++
UE4Editor-Engine.dll!UStaticMesh::PostLoad() Line 3676 C++

bool FLayoutUV::PackCharts():
- 9793 times - for( int32 i = 0; i < Charts.Num(); i++ )
- 8 times - for( int32 Orientation = 0; Orientation < 8; Orientation++ )
- 1024x1024 (~) - bool FAllocator2D::FindBitByBit( FRect& Rect, const FAllocator2D& Other )
- 10 seconds for around 300 itereations for the first loop. It was manual timing, so not accurate at all,
but it gives some measure to the timing, so I’ll with that for now. Meaning 320 seconds for PackCharts()

bool FLayoutUV::FindBestPacking()
- First (while) loop: “// Linear search for first fit” - 1 time (minimum, mine took 2) * PackCharts()
- second loop - 6 times (const):
// Binary search for best fit
for( int32 i = 0; i < BinarySearchSteps; i++ )
- another PackCharts() at the end of it

  • Minimum 8 times of PackCharts * 320 seconds = 2560 seconds = 42.666666666666666666666666666667 minutes.

So what is really going on here? which part of this code shouldn’t be done that is taking it so long?

I have ROG STRIX GL702VS. Although it’s a laptop, it’s a really strong one, and I managed to run some heavy stuff so far.
Even if some stuff should be slower because it’s a laptop - loading a static mesh for 40 minutes - a definitely no.

Even if my timing for the loop in PackCharts() is a bit off, and it would take 5 seconds, it’s still 20 minutes for a static mesh. A tree.
Still way too long then it should be.

1 Like

I have a relatively powerful PC and even I have to wait a while to load up Epic’s example content, particularly open world or some Paragon assets. Their packs are also very heavy on the file size, even the smaller ones. Not really sure what the cause is but that’s been my experience. =P

SE_JonF - Well good to know it’s not just my pc hehe.

But either way I think we should fix it. If not just the time that it takes to do the process, but the responsiveness / ui of it, or even allowing you cancel it. (I didn’t need it in my case).

Is there a place where I can create a feature request to epic :open_mouth: ?

Not sure if there’s a specific feature request form but there’s a bug tracker https://issues.unrealengine.com/
Also you can always open a pull request on github if you manage to fix it

Yea been my experience also, you can request up in the feedback thread i believe.