Skip to content

Commit

Permalink
Fix polyline update and removal bookkeeping
Browse files Browse the repository at this point in the history
Fixes CesiumGS#4983.

PolylineCollection stores a list of polylines that are waiting to be updated in the next render pass.  However, if a polyline is both updated _and_ removed in the same synchronous execution sequence, _and_ the polyline is near the end of the collection's internal `this._polylines` list, it's possible for the PolylineCollection to effectively read off the end of the array, causing an error "Batch Table instanceIndex out of range".

This is resolved by ensuring that removing a polyline from the collection also removes it from the list of polylines waiting to be updated.
  • Loading branch information
markerikson authored Apr 17, 2018
1 parent c32d946 commit adc7272
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Source/Scene/PolylineCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ define([
PolylineCollection.prototype.remove = function(polyline) {
if (this.contains(polyline)) {
this._polylines[polyline._index] = undefined; // Removed later

var polylineUpdateIndex = this._polylinesToUpdate.indexOf(polyline);
if(this._polylinesToUpdate.length && polylineUpdateIndex >= 0) {
this._polylinesToUpdate.splice(polylineUpdateIndex, 1);
}

this._polylinesRemoved = true;
this._createVertexArray = true;
this._createBatchTable = true;
Expand Down

0 comments on commit adc7272

Please sign in to comment.