GPU consumption when there is a CallbackProperty

Hi everyone,

I have a Cesium app and I am using the request reder mode. Usually the GPU consumption is very low, which it makes it perfect for low permonce computers. However, if I create a entity and I set a CallbackProperty to change the position the GPU consumption goes to the 100%.

This can be reproduced in the next sandcastle:

The only needed change is to add the next lines to the viewer constructor:

    requestRenderMode : true,
    maximumRenderTimeChange : Infinity

If you open the task manager you can see how the CPU and GPU consumtion is really low due to the render mode. However, when you start drawing a line consumption skyrockets even if you do not move the mouse.

Is this the expected behaviour or it is a bug?

Regards,

Ignacio.

Hey Ignacio,

I would consider this bug, but there’s some debate on whether using a CallbackProperty should essentially nullify request render mode. Here’s a related GitHub issue:

https://github.com/AnalyticalGraphicsInc/cesium/issues/6631

And my suggestion for giving the user access to explicitly control when an entity requires re-rendering:

https://github.com/AnalyticalGraphicsInc/cesium/issues/6631#issuecomment-461841873

Feel free to chime in there, or it might be worth opening a new issue for this idea of having explicit control over when an entity triggers a frame to render.

Hi Omar,

Thank you for your answer. Before opening a new issue in github I wanted to be sure this is a bug and not something that I am doing wrong. I will explain a little more the problem so maybe you can see a workaround that I did not found.

We are representing the field of view of a camera as a polygon in the map and we update the position of the polygon when the camera is moved (99% of the time the camera does not move). I can think of two solutions for this:

- I override the hierarchy of the PolygonGraphic when I received information about the camera and it is render in the next request render (I am in requestRenderMode). This worked ok in Cesium 1.50, but now that I have updated to 1.57 the polygon blinks all the time.

- I use the callbackProperty to update the hierarchy of the PolygonGraphic. The GPU goes to the 100% even if the polygon is static 99% of the time.

I am missing something? There is other way?

Maybe with some orientation I can contribute to implement the solution, if this is finnaly a bug and not a feature.

Thank you and regards,

Ignacio.

Ignacio,

If you can show that this used to work in 1.50 but no longer works in the latest version, I would consider it a bug and it might help motivate a fix faster. You can access Sandcastle examples for older versions of Cesium with a link like the one below which hosts version 1.50:

https://cesiumjs.org/releases/1.50/Apps/Sandcastle/index.html?src=Offline.html

You can replace the version number to get any older version of CesiumJS.

Ideally there would be a way to update a polygon without using a CallbackProperty for this situation when the update is infrequent and you have request render mode. Can you put together a code example for a polygon that updates its position with the camera that we can test in version 1.50 and 1.57? I think that will help guide a solution here.

Hi Omar,

I have discovered some interesting things playing with Cesium versions. Here is the code I am using and that you can use to verify my results:

var viewer = new Cesium.Viewer('cesiumContainer', {
    imageryProvider : Cesium.createTileMapServiceImageryProvider({
        url : Cesium.buildModuleUrl('Assets/Textures/NaturalEarthII')
    }),
    baseLayerPicker : false,
    geocoder : false,
    requestRenderMode : true,
    maximumRenderTimeChange : Infinity
});

var dataSource = new Cesium.CustomDataSource("custom");
viewer.dataSources.add(dataSource);

var redPolygon = dataSource.entities.add({
    name : 'Red polygon on surface',
    polygon : {
        hierarchy : Cesium.Cartesian3.fromDegreesArray([-115.0, 37.0,
                                                        -115.0, 32.0,
                                                        -107.0, 33.0,
                                                        -102.0, 31.0,
                                                        -102.0, 35.0]),
        material : Cesium.Color.RED
    }
});

setInterval(render, 500);
setInterval(updateArea, 2000);

function render(){
    viewer.scene.requestRender();
}

var i = 0;
function updateArea(){
    dataSource.entities.removeAll();
    
    var redPolygon = dataSource.entities.add({
    name : 'Red polygon on surface',
    polygon : {
        hierarchy : Cesium.Cartesian3.fromDegreesArray([-115.0, 37.0,
                                                        -115.0, 32.0,
                                                        -107.0, 33.0,
                                                        -102.0, 31.0,
                                                        -102.0 + i, 35.0 + i]),
        material : Cesium.Color.RED,
        perPositionHeight : true
    }
});
    
    i += 0.5;
}

The conclusions are:

1) This code works nice in version 1.50, the update of the shape is smooth with no blinking.

2) This code does NOT work in version 1.57, the polygon blink everytime is updated. To get the same smoothness I will need to use the CallbackProperty that leads to high GPU consumption.

3) If the property "perPositionHeight" of the polygon is removed it does not work in any of the versions.

I think it should work always as 1) so it migth be a bug.

Regards,

I’ve responded to your GitHub issue but I’m just seeing this now. For anyone else following this, see the GitHub issue here:

https://github.com/AnalyticalGraphicsInc/cesium/issues/7934

Thanks again for looking into this and documenting your results!