What error message do you see?
Chrome Dev Tool Crash error. Heap size is full.
Do both instances crash?
Yes, Whole application is crashed.
Can you elaborate on what you mean by “1100 iteration” - is that 1,100 frames?
I am updating polygon and polyline points in a recurssive function call. All data are coming from API as JSON and i am updating the points by parsing viewer.datasource.
On first iteration am adding the czml to datasource. Then on next iterations i am updating the points. please check below codes.
let iterationCount = 0;
let czml = ;
let polygonList = ;
let polyLineList = ;
processData();
var getData = function() {
var _responsePromise = $http({
url: "http://localhost:5000/api/getDetails",
method: 'GET'
});
return _responsePromise;
}
function processData() {
getData().then(function (response) {
polygonList = response.data.PolygonList;
polyLineList = response.data.PolylineList;
if(iterationCount == 0){
constructCZML();
}
drawOnMap(function(res) {
if(res.status == "Complete"){
iterationCount++;
processData();
}
});
});
}
function constructCZML() {
czml.push({
'id' : 'document',
'name' : 'CZML: Geometry',
'version' : '1.0'
},
{
"id": "polygonCircle",
"name": "polygonCircle",
"polygon": {
"positions": {
"cartographicDegrees": [],
},
"material": {
"solidColor": {
"color": {
"rgba": [255, 255, 255, 255]
}
}
},
"show": true
}
},
{
"id" : "polyline",
"name" : "polyline",
"polyline" : {
"positions" : {
"cartographicDegrees" : []
},
"material" : {
"solidColor" : {
"color" : {
"rgba" : [255, 0, 0, 255]
}
}
},
"width" : 2,
"clampToGround" : false,
"show": true
}
});
}
function drawOnMap() {
if(iterationCount == 1) {
//polyline
var _index = czml.findIndex(item => item.id == "polyline");
if(_index != -1){
var tempPolylineList = [];
for(var e = 0; e < polyLineList.length; e++) {
tempPolylineList.push(polyLineList[e].Lon, polyLineList[e].Lat, 0);
}
czml[_index].polygon.positions.cartographicDegrees = tempPolylineList;
czml[_index].polygon.show = true;
}
//polygon
var _index = czml.findIndex(item => item.id == "polygonCircle");
if(_index != -1){
var tempPolygonList = [];
for(var e = 0; e < polygonList.length; e++) {
tempPolygonList.push(polygonList[e].Lon, polygonList[e].Lat, 0);
}
czml[_index].polygon.positions.cartographicDegrees = tempPolygonList;
czml[_index].polygon.show = true;
}
viewer.dataSources.add(Cesium.CzmlDataSource.load(czml));
callback({ status: "Complete" });
}else if(iterationCount > 1){
for(var a = 0; a < viewer.dataSources._dataSources.length; a++){
var source = viewer.dataSources._dataSources[a];
if(source.name == "CZML: Geometry") {
if(polyLineList.length > 0){
var tempPolylineList = [];
for(var e = 0; e < polyLineList.length; e++) {
tempPolylineList.push(polyLineList[e].Lon, polyLineList[e].Lat, 0);
}
var polyline = source.entities.getById('polyline').polyline;
polyline.hierarchy.positions.setValue(Cesium.Cartesian3.fromDegreesArrayHeights(tempPolylineList));
}
if(polygonList.length > 0){
var tempPolygonList = [];
for(var j = 0; j < polygonList.length; j++) {
tempPolygonList.push(parseFloat(polygonList[j].Lon), parseFloat(polygonList[j].Lat));
}
var polygonCircle = source.entities.getById('polygonCircle').polygon;
polygonCircle.hierarchy.setValue(Cesium.Cartesian3.fromDegreesArray(tempPolygonList));
}
}
}
callback({ status: "Complete" });
}
}
Are you able to reproduce that consistently or does it only happen some of the time?
Yes, This happens every time i reached that iteration.
Note:
I have given one sample of czml. I have 30 to 40 drawing elements on the czml array.