Remove Instance (Foliage) - crash dedicated server

Hi! 4.14 Crash dedicated server, standalone.

[link text][3]

Hey ReduxRus-

For additional information, does the crash occur in the blueprint screenshot provided? If so, does it crash at the cast node or the remove instance node? Can you provide reproduction steps to help investigate the crash locally?

Hi!

We find bug in HierarchicalInstancedStaticMesh.cpp
This bug only on dedicate server!
Function BuildTreeAsync() is not work, this fixes:

HierarchicalInstancedStaticMesh.cpp
void UHierarchicalInstancedStaticMeshComponent::BuildTreeAsync()
{
 bool bMeshIsValid =
  // make sure we have instances
  PerInstanceSMData.Num() > 0 &&
  // make sure we have an actual staticmesh
  GetStaticMesh() &&
  GetStaticMesh()->HasValidRenderData() &&
  // You really can't use hardware instancing on the consoles with multiple elements because they share the same index buffer. 
  // @todo: Level error or something to let LDs know this
  1;//GetStaticMesh()->LODModels(0).Elements.Num() == 1;
  
  .
  .
  .
  .
}
  
  
"GetStaticMesh()->HasValidRenderData()" on dedicated server random return false

this my small fix for dedicated servers:

 // Verify that the mesh is valid before using it.
 bool bMeshIsValid =
  // make sure we have instances
  PerInstanceSMData.Num() > 0 &&
  // make sure we have an actual staticmesh
  GetStaticMesh() &&
  GetStaticMesh()->HasValidRenderData() &&
  // You really can't use hardware instancing on the consoles with multiple elements because they share the same index buffer. 
  // @todo: Level error or something to let LDs know this
  1;//GetStaticMesh()->LODModels(0).Elements.Num() == 1;

 if (GetNetMode() == NM_DedicatedServer)
 {
  bMeshIsValid =
   // make sure we have instances
   PerInstanceSMData.Num() > 0 &&
   // make sure we have an actual staticmesh
   GetStaticMesh() &&
   // You really can't use hardware instancing on the consoles with multiple elements because they share the same index buffer. 
   // @todo: Level error or something to let LDs know this
   1;
 }

Hey ReduxRus-

Since you already have a possible fix suggested, would you be able to submit that as a Pull Request on GitHub (https://github.com/EpicGames/UnrealEngine/compare?expand=1) ? That is our preferred method for receiving suggested fixes. If you are unable to do so, or prefer not to, let me know and I will get a ticket put in for this issue and mention your suggested fix there.

Cheers

Was this issue ever resolved? I’m still getting false when calling “GetStaticMesh()->HasValidRenderData()” on a dedicated server

Hey mgumley-

Are you getting a crash as well? If so, please provide the callstack for additional information. Additionally, where are you calling HasValidRenderData() from and at what point during runtime is it being called? What I mean by this is “Is the function call being made during startup or is it being called after the game has already been running?” Please let me know if there is any information you can provide to help me test the issue on my end.

HasValidRenderData() is being called by the engine’s HISM class. The engine is crashing itself, not my code. This post clearly shows how to reproduce the issue. You just need to try adding and removing instances on a dedicated server.

Please provide the callstack from your crash to help identify where in the code the crash is occurring. As for reproducing the issue, can you provide detailed reproduction steps? Since the original issue appears to be an “array out of bounds” error, I have tried adding/removing array elements as well as adding/removing to/from an hierarchical instance static mesh but did not receive any crash.

I have also encountered this bug. Is there any update on when it might be fixed?

Hey Rhynedahll-

Can you provide any details about what you’re experiencing? Are you seeing a crash in a dedicated server as well? How are you setting up the dedicated server / what are you doing that causes the crash?

Yes, the crash only occurs on the dedicated server, not in editor or, I have been told, on a listen server. When trying to remove foliage with a Remove Instance node the server will crash with an Array index out of bounds error.
I’ve just finished a test and the above patch does indeed fix the problem for me.

Is this fixed? maybe in 4.18? I ran into similar Problems in 4.17.3 when trying to remove a Instance of a Foliage with dedicated Server packaged version.

I haven’t seen a notice for a fix for this, but I do know that the engine modification shown above solves this problem. It’s a really simply code change.

The fix may not work in 4.18.2. The error has resurfaced in our project. Investigating now.

Part of the Callstack for current crash:
[2017.12.20-00.47.47:877][212]LogWindows: Error: [Callstack] 0x00000000FD2DA06D KERNELBASE.dll!UnknownFunction []
[2017.12.20-00.47.47:877][212]LogWindows: Error: [Callstack] 0x00000000403FB170 Colony2Server.exe!FWindowsErrorOutputDevice::Serialize() [e:\ue4.18\unrealengine\engine\source\runtime\applicationcore\private\windows\windowserroroutputdevice.cpp:65]
[2017.12.20-00.47.47:878][212]LogWindows: Error: [Callstack] 0x00000000401959FB Colony2Server.exe!FOutputDevice::Logf__VA() [e:\ue4.18\unrealengine\engine\source\runtime\core\private\misc\outputdevice.cpp:70]
[2017.12.20-00.47.47:878][212]LogWindows: Error: [Callstack] 0x0000000040128A88 Colony2Server.exe!FDebug::AssertFailed() [e:\ue4.18\unrealengine\engine\source\runtime\core\private\misc\assertionmacros.cpp:414]
[2017.12.20-00.47.47:879][212]LogWindows: Error: [Callstack] 0x0000000042C0F843 Colony2Server.exe!UHierarchicalInstancedStaticMeshComponent::RemoveInstanceInternal() [e:\ue4.18\unrealengine\engine\source\runtime\engine\private\hierarchicalinstancedstaticmesh.cpp:1856]
[2017.12.20-00.47.47:879][212]LogWindows: Error: [Callstack] 0x0000000042C0F74E Colony2Server.exe!UHierarchicalInstancedStaticMeshComponent::RemoveInstance() [e:\ue4.18\unrealengine\engine\source\runtime\engine\private\hierarchicalinstancedstaticmesh.cpp:1972]

in 4.17 this fix is still working.

We’ve recompiled the engine several times with the modification, but it does not appear to be working in 4.18.2 (Worked fine in 4.17.) . The server will always crash on attempting to remove a second foliage instance and the error is as above in the original post. Is anyone else encountering this problem with 4.18.2?

RemoveInstance is totally broken on Hierarchical Instanced Static Mesh Components right now, and has been for almost a year. When you remove an instance, it reorders or shrinks the array, causing all cached instance indices to become useless (either pointing to wrong instance or array out of bounds).

See here: [Bug] Instanced Static Mesh Component is broken in 4.17.1 - Asset Creation - Unreal Engine Forums

Currently the only way around this is a horribly inefficient kludge where you need to ClearInstances() then re-add all instances you didn’t want removed. It’s insanely inefficient with large sets of instances.

I will be monitoring this thread. I’m really hoping Epic will work the bugs out of ISMCs/HISMCs, as it’s a powerful feature that is otherwise completely unusable in its current broken state.

Also see this thread for more bugs: Lets talk about bug report UE-43692 - Programming & Scripting - Unreal Engine Forums

I made a git patch that seems to fix the problem in 4.18.2. Just apply it to the UE 4.18.2 release commit. Please let me know if this does or doesn’t work for you. [(patch.zip)][1]

It is readable with a text editor, so you can manually apply it if you want to. Here is the summary:

Thank you for this! Looks like it was freaking out when a headless server wasn’t actually rendering the mesh.