Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bad_any_cast errors by disabling RTTI when building cesium-native #1468

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

### ? - ?

##### Fixes :wrench:

- Fixed a bug that could cause a `bad_any_cast` exception when trying to access glTF extensions on non-Windows platforms. This commonly popped up when loading tilesets with metadata.
- Fixed a bug that caused the `GetInteger64` functions on `CesiumMetadataValue`, `CesiumPropertyArray`, and `CesiumPropertyTableProperty` to always return the default value on non-Windows platforms.

### v2.7.0 - 2024-07-01

##### Additions :tada:
Expand Down
6 changes: 3 additions & 3 deletions Source/CesiumRuntime/Private/CesiumMetadataValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ int64 UCesiumMetadataValueBlueprintLibrary::GetInteger64(
int64 DefaultValue) {
return std::visit(
[DefaultValue](auto value) -> int64 {
return CesiumGltf::MetadataConversions<int64, decltype(value)>::convert(
value)
.value_or(DefaultValue);
return CesiumGltf::MetadataConversions<int64_t, decltype(value)>::
convert(value)
.value_or(DefaultValue);
},
Value._value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ int64 UCesiumPropertyArrayBlueprintLibrary::GetInteger64(
return defaultValue;
}
auto value = v[index];
return CesiumGltf::MetadataConversions<int64, decltype(value)>::convert(
value)
.value_or(defaultValue);
return CesiumGltf::MetadataConversions<int64_t, decltype(value)>::
convert(value)
.value_or(defaultValue);
},
array._value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ int64 UCesiumPropertyTablePropertyBlueprintLibrary::GetInteger64(
auto maybeValue = v.get(FeatureID);
if (maybeValue) {
auto value = *maybeValue;
return CesiumGltf::MetadataConversions<int64, decltype(value)>::
return CesiumGltf::MetadataConversions<int64_t, decltype(value)>::
convert(value)
.value_or(DefaultValue);
}
Expand Down
6 changes: 3 additions & 3 deletions extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ set(CMAKE_RELWITHDEBINFO_POSTFIX ${CESIUM_RELEASE_POSTFIX})
# On Mac and Linux, Unreal uses -fvisibility-ms-compat.
# On Android, it uses -fvisibility=hidden
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-ms-compat -fvisibility-inlines-hidden")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-ms-compat -fvisibility-inlines-hidden -fno-rtti")
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Android")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden -fno-rtti")
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fno-rtti")
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
# Unreal Engine adds /Zp8 in 64-bit Windows builds to align structs to 8 bytes instead of the
# default of 16 bytes. There's this nice note in the documentation for that option:
Expand Down