CesiumGS / cesium-unreal

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

Crashes running in standalone mode #1289

Closed FLYPoPo7 closed 9 months ago

FLYPoPo7 commented 11 months ago

Environment

OS windows 10 UE v5.3.1 Cesium for Unreal v2.0.0 It can be reproduced in the Cesium for Unreal Samples.

Reproduce

It can be reproduced in the Cesium for Unreal Samples. Just Open Map 01_CesiumWorld and run it in standalone mode.

Error Message

LoginId:8a8c83a3480311a4b6e32c92b291485b
EpicAccountId:6c7d257aacaa497daf4dbab23bdfbad3

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000002100

UnrealEditor_CesiumRuntime!ACesium3DTileset::PostLoad() [D:\build\U5M-Marketplace\Sync\LocalBuilds\PluginTemp\HostProject\Plugins\CesiumForUnreal\Source\CesiumRuntime\Private\Cesium3DTileset.cpp:2090]
UnrealEditor_CoreUObject!UObject::ConditionalPostLoad() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Obj.cpp:1269]
UnrealEditor_CoreUObject!EndLoad() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:2211]
UnrealEditor_CoreUObject!`LoadPackageInternal'::`102'::<lambda_2>::operator()() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1751]
UnrealEditor_CoreUObject!LoadPackageInternal() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1853]
UnrealEditor_CoreUObject!LoadPackage() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:2014]
UnrealEditor_CoreUObject!LoadPackage() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1987]
UnrealEditor_Engine!UEngine::LoadMap() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\UnrealEngine.cpp:15001]
UnrealEditor_Engine!UEngine::Browse() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\UnrealEngine.cpp:14390]
UnrealEditor_Engine!UGameInstance::StartGameInstance() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\GameInstance.cpp:644]
UnrealEditor_Engine!UGameEngine::Start() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\GameEngine.cpp:1211]
UnrealEditor!FEngineLoop::Init() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:4855]
UnrealEditor!GuardedMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:168]
UnrealEditor!GuardedMainWrapper() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:118]
UnrealEditor!LaunchWindowsStartup() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:258]
UnrealEditor!WinMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:298]
UnrealEditor!__scrt_common_main_seh() [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
kernel32
ntdll

I guess it may caused by CesiumActors::shouldValidateFlags function.

bool CesiumActors::shouldValidateFlags(UObject* object) {
#if WITH_EDITOR
  // Only fixup flags in the editor, when not in play mode
  if (GEditor->IsPlaySessionInProgress())
    return false;

  // In addition, don't fix when loading from an asset file, which sets the
  // RF_ClassDefaultObject and RF_ArchetypeObject flags.
  if (object->HasAnyFlags(RF_ClassDefaultObject) ||
      object->HasAnyFlags(RF_ArchetypeObject))
    return false;
  else
    return true;
#else
  return false;
#endif
}
kring commented 11 months ago

I can reproduce this. It seems that in a Standalone Game, WITH_EDITOR is defined, yet GEditor is nullptr. We need a null check in shouldValidateFlags.

image

We'd appreciate a pull request to fix this if you're up for it, @FLYPoPo7!

armygamestudio commented 11 months ago

// Only fixup flags in the editor, when not in play mode if (IsValid(GEditor) && GEditor->IsPlaySessionInProgress()) return false;

Adding the IsValid(GEditor) check fixes the issue for us. Using: CesiumForUnreal-52-v2.0.0

kring commented 11 months ago

Makes sense to me, @armygamestudio. Would love if you could open a pull request with that change.

kring commented 11 months ago

Actualy, a slightly better fix would be to return false when GEditor isn't valid. So:

// Only fixup flags in the editor, when not in play mode
if (!IsValid(GEditor) || GEditor->IsPlaySessionInProgress())
  return false;
NicoLee777 commented 11 months ago

Actualy, a slightly better fix would be to return false when GEditor isn't valid. So:

// Only fixup flags in the editor, when not in play mode
if (!IsValid(GEditor) || GEditor->IsPlaySessionInProgress())
  return false;

Hi,May I ask where is this code to be written?

kring commented 11 months ago

@NicoLee777 just search for that comment in the code, it'll pop right up.

TonyWang972 commented 9 months ago

I'm still having this problem with the new version OS windows 11 UE v5.3.2 Cesium for Unreal v2.2.0 `LoginId:3974f5af4246bbebe07c1db695afc0c4 EpicAccountId:26489ffc80134b54a04ec2cca0b92925

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000002100

UnrealEditor_CesiumRuntime!ACesium3DTileset::PostLoad() [D:\build\U5M-Marketplace\Sync\LocalBuilds\PluginTemp\HostProject\Plugins\CesiumForUnreal\Source\CesiumRuntime\Private\Cesium3DTileset.cpp:2094] UnrealEditor_CoreUObject UnrealEditor_CoreUObject UnrealEditor_CoreUObject UnrealEditor_CoreUObject UnrealEditor_CoreUObject UnrealEditor_CoreUObject UnrealEditor_Engine UnrealEditor_Engine UnrealEditor_Engine UnrealEditor_Engine UnrealEditor UnrealEditor UnrealEditor UnrealEditor UnrealEditor UnrealEditor kernel32 ntdll`

kring commented 9 months ago

The fix for this issue hasn't been released yet. You can try it out today by trying a pre-release build from the main branch by following these instructions: https://github.com/CesiumGS/cesium-unreal/blob/main/Documentation/using-prerelease-packages.md#download-a-pre-release-version-from-a-branch-or-commit

Or you can wait for the next official release, which will be next week.

TonyWang972 commented 9 months ago

The fix for this issue hasn't been released yet. You can try it out today by trying a pre-release build from the branch by following these instructions: https://github.com/CesiumGS/cesium-unreal/blob/main/Documentation/using-prerelease-packages.md#download-a-pre-release-version-from-a-branch-or-commit`main`

Or you can wait for the next official release, which will be next week.

thank you