Crash loading implicit tileset
j9liu opened this issue · comments
Adding asset 2325107 from the CesiumJS ion account results in a crash in Unreal Engine. Every time it crashes, it is on a different line, but it always seems to involve a callstack related to Cesium Native:
In particular, the crashes are happening in Cesium3DTilesReader::SubtreeReader::readFromJson
.
I believe it has to do with the Native changes. I produced this crash on Cesium for Unreal on the multiple-cesium-ions branch
, which uses the changes. However, loading this dataset doesn't crash Cesium for Unity, which hasn't been updated for Cesium Native.
I probably ran into the same issue - could it be
https://github.com/CesiumGS/cesium-native/blob/main/Cesium3DTilesContent/src/SubtreeAvailability.cpp#L149
https://github.com/CesiumGS/cesium-native/blob/main/Cesium3DTilesReader/src/SubtreeFileReader.cpp#L30
Where the reader
is allocated on stack and later being used on another worker thread?
This fixes the crash for me
--------------- Cesium3DTilesContent/src/SubtreeAvailability.cpp ---------------
index da2504b0..7c880821 100644
@@ -142,18 +142,18 @@ SubtreeAvailability::loadSubtree(
ImplicitTileSubdivisionScheme subdivisionScheme,
uint32_t levelsInSubtree,
const CesiumAsync::AsyncSystem& asyncSystem,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
const std::shared_ptr<spdlog::logger>& pLogger,
const std::string& subtreeUrl,
const std::vector<CesiumAsync::IAssetAccessor::THeader>& requestHeaders) {
- SubtreeFileReader reader;
- return reader.load(asyncSystem, pAssetAccessor, subtreeUrl, requestHeaders)
+ auto reader = std::make_shared<SubtreeFileReader>();
+ return reader->load(asyncSystem, pAssetAccessor, subtreeUrl, requestHeaders)
.thenInMainThread(
- [pLogger, subtreeUrl, subdivisionScheme, levelsInSubtree](
+ [pLogger, subtreeUrl, subdivisionScheme, levelsInSubtree, reader](
ReadJsonResult<Subtree>&& subtree)
-> std::optional<SubtreeAvailability> {
if (!subtree.value) {
if (!subtree.errors.empty()) {
SPDLOG_LOGGER_ERROR(
pLogger,
"Errors while loading subtree from {}:\n- {}",
Makes sense to me @pjanetzek!
Thanks @pjanetzek ! Would you be able to open a PR with the fix?
Hey @j9liu does the implicit_quadtree now work for you with Unreal? I ask because I'm investigating a tile loading issue where Cesium is embedded in our enginge in a more complicated fashion - and since updating from 0.25 to 0.30 the subtrees TileLoadResultState is never set to Success..
Right now I'm looking at https://github.com/CesiumGS/cesium-native/blob/main/Cesium3DTilesContent/src/SubtreeAvailability.cpp#L99
it seems contentAvailability is not parsed correctly from this json, therefore exiting the function on line 99.
{
"tileAvailability": {
"constant": 1
},
"contentAvailability": {
"constant": 1
},
"childSubtreeAvailability": {
"constant": 0
}
}
Sorry the problem was on my side, as it appears contentAvailability must be an array now