Drawing polygons crash the whole Cesium vieport

1. A concise explanation of the problem you’re experiencing.

We are drawing polygons, and, among 1500+ polygons we draw there are particular two which make Cesium crash. Any one of these two works fine, but two drawn together appears to be deadly for Cesium. Need help figuring out what makes these two polygons so special to cause such an effect so we could get it under control.

Following code illustrates the matter. It can be copied to Sandcastle and run to see the crash.

Suggestions?

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var polys =

[

“172.634577109946,-43.5297673648253,0 172.634804217336,-43.529495739866,0 172.634806485168,-43.5294930288697,0 172.634861434736,-43.5294273070786,0 172.63494253963,-43.5293130740366,0 172.635009486553,-43.5292016873973,0 172.635114926283,-43.5290395485974,0 172.635114417915,-43.5288578214237,0 172.635301832678,-43.5288575599225,0 172.635408591283,-43.5288574118932,0 172.635599024564,-43.5288571506268,0 172.635607810592,-43.5288571384131,0 172.63566038171,-43.5288570665048,0 172.635662432337,-43.5288570636994,0 172.635662432432,-43.5288570624672,0 172.636245599313,-43.5288562513054,0 172.636260035845,-43.5288562340014,0 172.636496957722,-43.528855901815,0 172.636497169339,-43.5289387006143,0 172.636497389941,-43.5290241274363,0 172.636497536498,-43.5290825429202,0 172.636498133855,-43.5293102642739,0 172.636498648162,-43.5295082916736,0 172.636498648325,-43.5295103618935,0 172.636498648185,-43.5295124230153,0 172.636498799238,-43.5295701455729,0 172.636498801941,-43.5295717297606,0 172.636499266063,-43.5297491722762,0 172.636478143775,-43.5297645959975,0 172.636157010028,-43.5297650671343,0 172.635513406837,-43.5297660022342,0 172.634730804991,-43.5297671412286,0 172.634577109946,-43.5297673648253,0”,

“172.632717748155,-43.5252174117892,0 172.632718750085,-43.5252174149852,0 172.632718749997,-43.5252174111734,0 172.632717748064,-43.5252174079776,0 172.632717748155,-43.5252174117892,0”

];

for (var i in polys)

{

var poly = polys[i];

var degarray = ;

var pts = poly.split(’ ');

for (var i in pts)

{

var pt = pts[i].trim();

var coords = pt.split(’,’);

if (coords.length>1)

{

var lng = parseFloat(coords[0]);

var lat = parseFloat(coords[1]);

degarray.push(lng);

degarray.push(lat);

}

}

viewer.entities.add

({

name : name,

polygon :

{

hierarchy : Cesium.Cartesian3.fromDegreesArray(degarray),

heightReference : Cesium.HeightReference.CLAMP_TO_GROUND,

clampToGround : true

}

});

}

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

The answer to this should be obvious.

4. The Cesium version you’re using, your operating system and browser.

Cesium 1.50. Chrome. Tried on both Windows and Lynux - both crash.

Hey Alex,

Thanks for reporting this and providing a code sample.

So the first thing I noticed is that it only crashes when the heightReference is set. (The PolygonGraphics doesn’t actually take a “clampToGround” property so I don’t think that’s doing anything there).

I modified your example slightly to zoom into the first polygon, and it’s not crashing. See the example here. By default polygons should be clamped to ground, so I think this should do what you need.

I don’t see the second polygon though. I wonder if it’s just too small? Do you know where it’s expected to show up? Were you able to just display the second polygon on its in Cesium?

It seems like the crash was coming from an inability to compute the second polygon’s bounding sphere, which may or may not be a bug. Can you confirm what this polygon is expected to look like when displayed?

Thank you Omar,
much appreciate you coming back to us on this. I will try to answer to your question - "Can you confirm what this polygon is expected to look like when displayed?"

The intention was to use Cesium to draw the polygons to see them, and the fact that Cesium crashes is very discouraging. I am not sure what should be done to validate the polygons before attempting to feed them to Cesium for drawing to ensure Cesium does not crash. We did not provision for the process of such validation because we were counting on Cesium to stay intact. If some polygon cannot be displayed - we can perhaps live with that as long as the rest of the Cesium functionality remains intact. In other words, "cannot draw the polygon - fine, but don't die like this on us please dear Cesium."

Moving the camera to each polygon we render is also not an option. We have polygons that cover the whole country, 1500+ of them. Flying the camera to each of them sequentially would ruin the user experience.

The suggestion about not setting "clampToGround" is very valuable. We do want clamping of polygons to the ground, but we can perhaps try not to set this attribute to preserve the working state of Cesium.

That second polygon is very small with two sides about 0.04 centimeter long. Not a renderer/shader guy, but do you expect items that small?

Scott

BTW, it didn’t crash for me using Cesium head on Chrome 70.0.3538.67 with NVIDIA Quadro M1000M.

Also, just to be clear, polygons are clamped to ground by default (unless you specify a non zero height). So your application should work just fine and all polygons should be clamped even when you remove that setting, since I see that you aren’t setting a positive height.

Please let me know if this isn’t the case.