Skip to content

Commit 4f888c2

Browse files
author
Hannah
authored
Merge pull request #6558 from AnalyticalGraphicsInc/stats-bug
Fix statistics for tiles that fail processing
2 parents c76001e + cc2ea04 commit 4f888c2

File tree

3 files changed

+59
-24
lines changed

3 files changed

+59
-24
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Change Log
2020

2121
##### Fixes :wrench:
2222
* Fixed a bug causing custom TilingScheme classes to not be able to use a GeographicProjection. [#6524](https://github.com/AnalyticalGraphicsInc/cesium/pull/6524)
23+
* Fixed incorrect 3D Tiles statistics when a tile fails during processing. [#6558](https://github.com/AnalyticalGraphicsInc/cesium/pull/6558)
2324
* Fixed race condition causing intermittent crash when changing geometry show value [#3061](https://github.com/AnalyticalGraphicsInc/cesium/issues/3061)
2425
* `ProviderViewModel`s with no category are displayed in an untitled group in `BaseLayerPicker` instead of being labeled as `'Other'` [#6574](https://github.com/AnalyticalGraphicsInc/cesium/pull/6574)
2526

Source/Scene/Cesium3DTileset.js

+26-24
Original file line numberDiff line numberDiff line change
@@ -1435,25 +1435,8 @@ define([
14351435

14361436
++statistics.numberOfPendingRequests;
14371437

1438-
var removeFunction = removeFromProcessingQueue(tileset, tile);
14391438
tile.contentReadyToProcessPromise.then(addToProcessingQueue(tileset, tile));
1440-
tile.contentReadyPromise.then(function() {
1441-
removeFunction();
1442-
tileset.tileLoad.raiseEvent(tile);
1443-
}).otherwise(function(error) {
1444-
removeFunction();
1445-
var url = tile._contentResource.url;
1446-
var message = defined(error.message) ? error.message : error.toString();
1447-
if (tileset.tileFailed.numberOfListeners > 0) {
1448-
tileset.tileFailed.raiseEvent({
1449-
url : url,
1450-
message : message
1451-
});
1452-
} else {
1453-
console.log('A 3D tile failed to load: ' + url);
1454-
console.log('Error: ' + message);
1455-
}
1456-
});
1439+
tile.contentReadyPromise.then(handleTileSuccess(tileset, tile)).otherwise(handleTileFailure(tileset, tile));
14571440
}
14581441

14591442
function requestTiles(tileset, outOfCore) {
@@ -1476,15 +1459,32 @@ define([
14761459
};
14771460
}
14781461

1479-
function removeFromProcessingQueue(tileset, tile) {
1480-
return function() {
1481-
if (tile._contentState === Cesium3DTileContentState.FAILED) {
1482-
// Not in processing queue
1483-
// For example, when a url request fails and the ready promise is rejected
1462+
function handleTileFailure(tileset, tile) {
1463+
return function(error) {
1464+
if (tileset._processingQueue.indexOf(tile) >= 0) {
1465+
// Failed during processing
1466+
--tileset._statistics.numberOfTilesProcessing;
1467+
} else {
1468+
// Failed when making request
14841469
--tileset._statistics.numberOfPendingRequests;
1485-
return;
14861470
}
14871471

1472+
var url = tile._contentResource.url;
1473+
var message = defined(error.message) ? error.message : error.toString();
1474+
if (tileset.tileFailed.numberOfListeners > 0) {
1475+
tileset.tileFailed.raiseEvent({
1476+
url : url,
1477+
message : message
1478+
});
1479+
} else {
1480+
console.log('A 3D tile failed to load: ' + url);
1481+
console.log('Error: ' + message);
1482+
}
1483+
};
1484+
}
1485+
1486+
function handleTileSuccess(tileset, tile) {
1487+
return function() {
14881488
--tileset._statistics.numberOfTilesProcessing;
14891489

14901490
if (tile.hasRenderableContent) {
@@ -1498,6 +1498,8 @@ define([
14981498
tile.replacementNode = tileset._replacementList.add(tile);
14991499
}
15001500
}
1501+
1502+
tileset.tileLoad.raiseEvent(tile);
15011503
};
15021504
}
15031505

Specs/Scene/Cesium3DTilesetSpec.js

+32
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,38 @@ defineSuite([
480480
fail('should not resolve');
481481
}).otherwise(function(error) {
482482
expect(root._contentState).toEqual(Cesium3DTileContentState.FAILED);
483+
var statistics = tileset.statistics;
484+
expect(statistics.numberOfAttemptedRequests).toBe(0);
485+
expect(statistics.numberOfPendingRequests).toBe(0);
486+
expect(statistics.numberOfTilesProcessing).toBe(0);
487+
expect(statistics.numberOfTilesWithContentReady).toBe(0);
488+
});
489+
});
490+
});
491+
492+
it('handles failed tile processing', function() {
493+
viewRootOnly();
494+
var tileset = scene.primitives.add(new Cesium3DTileset({
495+
url : tilesetUrl
496+
}));
497+
return tileset.readyPromise.then(function(tileset) {
498+
// Start spying after the tileset json has been loaded
499+
spyOn(Resource._Implementations, 'loadWithXhr').and.callFake(function(url, responseType, method, data, headers, deferred, overrideMimeType) {
500+
deferred.resolve(Cesium3DTilesTester.generateBatchedTileBuffer({
501+
version : 0 // Invalid version
502+
}));
503+
});
504+
scene.renderForSpecs(); // Request root
505+
var root = tileset._root;
506+
return root.contentReadyPromise.then(function() {
507+
fail('should not resolve');
508+
}).otherwise(function(error) {
509+
expect(root._contentState).toEqual(Cesium3DTileContentState.FAILED);
510+
var statistics = tileset.statistics;
511+
expect(statistics.numberOfAttemptedRequests).toBe(0);
512+
expect(statistics.numberOfPendingRequests).toBe(0);
513+
expect(statistics.numberOfTilesProcessing).toBe(0);
514+
expect(statistics.numberOfTilesWithContentReady).toBe(0);
483515
});
484516
});
485517
});

0 commit comments

Comments
 (0)