CesiumGS / cesium-unreal

Bringing the 3D geospatial ecosystem to Unreal Engine
https://cesium.com/platform/cesium-for-unreal/
Apache License 2.0
918 stars 293 forks source link

Runtime crash related to CesiumIonServer in a packaged game when tilesets are _only_ created at runtime #1507

Open kring opened 3 weeks ago

kring commented 3 weeks ago

Reported here: https://community.cesium.com/t/fatal-error-while-spawning-cesium3dtileset/34641

When a Cesium3DTileset is added via the Editor, it will have a reference to a CesiumIonServer instance (usually the default SaaS one) and so Unreal will know to automatically include this instance in a packaged game.

However, if your level does not have a Cesium3DTileset, but then you add one at runtime, Unreal won't know that the CesiumIonServer instance is required, and so it won't include it in the packaged game. As a result, the reference will be nullptr and the game will crash with an access violation.

This can be worked around by explicitly telling Unreal to include the CesiumIonServer. But it manifests as a mysterious crash to users, which is not great. We should address this by doing one or more of the following:

  1. Tell the user at runtime that this is a problem and fail gracefully instead of crashing with an access violation.
  2. Handle the possibility that there is no CesiumIonServer at runtime, and create one on the fly (like we already do in the Editor).
  3. Always force the CesiumIonServer to be included in packaged games even if it doesn't appear to be used.

We should also consider if there are other assets that will be missing in this scenario.

spikhoff commented 3 weeks ago

I'm just adding stack trace from that forum post:

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000080
0x00007ff64b3086d7 AutoVrtlEnv.exe!FString::FString() []
0x00007ff65449a0a5 AutoVrtlEnv.exe!ACesium3DTileset::LoadTileset() [C:\TEMP\Bsim3d_2709503_12248\AutoVrtlEnv\Plugins\CesiumForUnreal\Source\CesiumRuntime\Private\Cesium3DTileset.cpp:1196]
0x00007ff65449a884 AutoVrtlEnv.exe!ACesium3DTileset::OnConstruction() [C:\TEMP\Bsim3d_2709503_12248\AutoVrtlEnv\Plugins\CesiumForUnreal\Source\CesiumRuntime\Private\Cesium3DTileset.cpp:660]
0x00007ff65080633c AutoVrtlEnv.exe!AActor::ExecuteConstruction() []
0x00007ff650791429 AutoVrtlEnv.exe!AActor::FinishSpawning() []
0x00007ff6507a8219 AutoVrtlEnv.exe!AActor::PostSpawnInitialize() []
0x00007ff651388bc7 AutoVrtlEnv.exe!UWorld::SpawnActor() []
0x00007ff65138904e AutoVrtlEnv.exe!UWorld::SpawnActor() []
0x00007ff654c3487b AutoVrtlEnv.exe!UWorld::SpawnActor<ACesium3DTileset>() [C:\Program Files\Epic Games\UE_5.3\Engine\Source\Runtime\Engine\Classes\Engine\World.h:3463]