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 statistics for tiles that fail processing #6558

Merged
merged 4 commits into from
May 9, 2018
Merged
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Change Log

##### Fixes :wrench:
* Fixed a bug causing custom TilingScheme classes to not be able to use a GeographicProjection. [#6524](https://github.com/AnalyticalGraphicsInc/cesium/pull/6524)
* Fixed incorrect 3D Tiles statistics when a tile fails during processing. [#6558](https://github.com/AnalyticalGraphicsInc/cesium/pull/6558)
* Fixed race condition causing intermittent crash when changing geometry show value [#3061](https://github.com/AnalyticalGraphicsInc/cesium/issues/3061)
* `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)

Expand Down
50 changes: 26 additions & 24 deletions Source/Scene/Cesium3DTileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -1435,25 +1435,8 @@ define([

++statistics.numberOfPendingRequests;

var removeFunction = removeFromProcessingQueue(tileset, tile);
tile.contentReadyToProcessPromise.then(addToProcessingQueue(tileset, tile));
tile.contentReadyPromise.then(function() {
removeFunction();
tileset.tileLoad.raiseEvent(tile);
}).otherwise(function(error) {
removeFunction();
var url = tile._contentResource.url;
var message = defined(error.message) ? error.message : error.toString();
if (tileset.tileFailed.numberOfListeners > 0) {
tileset.tileFailed.raiseEvent({
url : url,
message : message
});
} else {
console.log('A 3D tile failed to load: ' + url);
console.log('Error: ' + message);
}
});
tile.contentReadyPromise.then(handleTileSuccess(tileset, tile)).otherwise(handleTileFailure(tileset, tile));
}

function requestTiles(tileset, outOfCore) {
Expand All @@ -1476,15 +1459,32 @@ define([
};
}

function removeFromProcessingQueue(tileset, tile) {
return function() {
if (tile._contentState === Cesium3DTileContentState.FAILED) {
// Not in processing queue
// For example, when a url request fails and the ready promise is rejected
function handleTileFailure(tileset, tile) {
return function(error) {
if (tileset._processingQueue.indexOf(tile) >= 0) {
// Failed during processing
--tileset._statistics.numberOfTilesProcessing;
} else {
// Failed when making request
--tileset._statistics.numberOfPendingRequests;
return;
}

var url = tile._contentResource.url;
var message = defined(error.message) ? error.message : error.toString();
if (tileset.tileFailed.numberOfListeners > 0) {
tileset.tileFailed.raiseEvent({
url : url,
message : message
});
} else {
console.log('A 3D tile failed to load: ' + url);
console.log('Error: ' + message);
}
};
}

function handleTileSuccess(tileset, tile) {
return function() {
--tileset._statistics.numberOfTilesProcessing;

if (tile.hasRenderableContent) {
Expand All @@ -1498,6 +1498,8 @@ define([
tile.replacementNode = tileset._replacementList.add(tile);
}
}

tileset.tileLoad.raiseEvent(tile);
};
}

Expand Down
32 changes: 32 additions & 0 deletions Specs/Scene/Cesium3DTilesetSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,38 @@ defineSuite([
fail('should not resolve');
}).otherwise(function(error) {
expect(root._contentState).toEqual(Cesium3DTileContentState.FAILED);
var statistics = tileset.statistics;
expect(statistics.numberOfAttemptedRequests).toBe(0);
expect(statistics.numberOfPendingRequests).toBe(0);
expect(statistics.numberOfTilesProcessing).toBe(0);
expect(statistics.numberOfTilesWithContentReady).toBe(0);
});
});
});

it('handles failed tile processing', function() {
viewRootOnly();
var tileset = scene.primitives.add(new Cesium3DTileset({
url : tilesetUrl
}));
return tileset.readyPromise.then(function(tileset) {
// Start spying after the tileset json has been loaded
spyOn(Resource._Implementations, 'loadWithXhr').and.callFake(function(url, responseType, method, data, headers, deferred, overrideMimeType) {
deferred.resolve(Cesium3DTilesTester.generateBatchedTileBuffer({
version : 0 // Invalid version
}));
});
scene.renderForSpecs(); // Request root
var root = tileset._root;
return root.contentReadyPromise.then(function() {
fail('should not resolve');
}).otherwise(function(error) {
expect(root._contentState).toEqual(Cesium3DTileContentState.FAILED);
var statistics = tileset.statistics;
expect(statistics.numberOfAttemptedRequests).toBe(0);
expect(statistics.numberOfPendingRequests).toBe(0);
expect(statistics.numberOfTilesProcessing).toBe(0);
expect(statistics.numberOfTilesWithContentReady).toBe(0);
});
});
});
Expand Down