Errors when changing the datasources of Viewer with InfoBox open

Hi ~ guys,

Yesterday, I updated Cesium from V1.4 to V1.9, there a some abnormal things occurred.

In my project, there is a group of radio selectors for user to choosing geojson data file and loading it into cesium.

When user click the loaded data, cesium’s InfoBox widget will popup and show some details of selected entity.

The abnormal scenario is : I always get a exception when I load a new geojson data with InfoBox open.

If I close the InfoBox widget, the data source changing operation is doing well.

The exception threw out as below:

An error occurred while rendering. Rendering has stopped.

DeveloperError: This object was destroyed, i.e., destroy() was called.


at new DeveloperError (

at throwOnDestroyed (

at Batch.getBoundingSphere (

at StaticGeometryColorBatch.getBoundingSphere (

at GeometryVisualizer.getBoundingSphere (

at DataSourceDisplay.getBoundingSphere (

at Viewer._onTick (

at Event.raiseEvent (

at Clock.tick (

at CesiumWidget.render (

Thanks a lot for your help !!

Is it possible to demonstrate this error in the Sandcastle?

When writing the code in Sandcastle, I found maybe I should call the viewer.dataSources.removeAll() function before load next geojson data, other than call the viewer.dataSources.remove(dataSource, destroy) function.

After I have tried the above, the problem is solved.

So, I try to do some tests for the viewer.dataSources.remove() function as below in Sandcastle :

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

var ds = null;

Sandcastle.addToolbarButton(‘add foo’, function() {

loadData(’…/…/SampleData/ne_10m_us_states.topojson’, {

fill: Cesium.Color.PINK,

strokeWidth: 3



Sandcastle.addToolbarButton(‘add bar’, function() {

loadData(’…/…/SampleData/ne_10m_us_states.topojson’, {

fill: Cesium.Color.RED,

strokeWidth: 3



function loadData(url, style) {

if(ds != null) {

viewer.dataSources.remove(ds, true);



ds = Cesium.GeoJsonDataSource.load(url, style);



The test result show that viewer.dataSource.remove(ds, true) always failed and return false.

Maybe there are some mistakes in my code.

It’s very kind of you if you can point it out to me.

Thanks !

Cesium.GeoJsonDataSource.load(url, style)
    .then(function (data) {
        dataSource = data;


GeoJsonDataSource.load returns a Promise, not the resolved dataSource itself.

viewer.dataSources.add(…) accepts either a Promise or a dataSource object so it was able to resolve the dataSource from the Promise.