GPU is not out of memory but Cesium raises an error: WebGLRenderingContext.shaderSource: Argument 1 is not an object

Hello.

This is Eric. I found a weird situation.

When I use Cesium to continuously change viewports on the 3D tiles for a long time, the following error happens.


An error occurred while rendering. Rendering has stopped.

TypeError: WebGLRenderingContext.shaderSource: Argument 1 is not an object.


From my observation, the usage of GPU was not beyond the limit when the error happened randomly after several hours.

It seems the WebGL loses context due to its long-term utilization.

Is there any way I can monitor it and refresh my browser to avoid it?

Or do you have any suggestions to improve the situation?

I appreciate your answers very much.

Thanks.

Eric.

Hi @EricLee,

How consistently does this problem occur? Are you able to make a Sandcastle that can reproduce the problem?

I’m not sure this has to do with memory usage, the error message sounds like an incorrect parameter (perhaps undefined?) is getting passed to gl.shaderSource(). Since you mentioned it only happening after a few hours, I wonder if it has anything to do with the ShaderCache, though I’d need more context to know for sure.

I see there was an old thread with a similar error, though that thread seems inconclusive.

Best,
Peter

Hi! @ptrgags

I may not be able to reproduce it on the Sandcastle because it needs a lot of time.

I also tested the program according to your clues. Indeed, the GPU memory was not full. But I observed that the main memory was nearly full before the program crashed. I guess it was because the firefox browser could not effectively release the memory, which made the whole computer respond slowly and then lead to the WebGLRenderingContext error.

Is it due to the ShaderCache? Or it is just the browser issue? How can release the memory occupied by the browser or program?

Thanks and best regards,

Eric.

@EricLee

Sorry for the delay.

What you mentioned about CPU memory being full does sound relevant. Looking at the relevant code in the renderer, I do wonder if running out of memory would cause problems with these lines.

Could you provide more information about how your scene is set up? Are there a lot of different tilesets or other primitives being rendered or just one tileset? Are you adding more objects to the scene over time or just at the start?

As far as releasing memory from CesiumJS primitives, the main way is to call viewer.scene.primitives.remove() or removeAll(). When a primitive is removed, it calls primitive.destroy() which cleans up memory associated with that resource.

Best,
Peter

@ptrgags

Thanks for your reply.

A new observation is that the error has not occurred since I reduced the amount of printed information in the console log when running the program.

I put several big tilesets on the Cesium platform just at the start. Viewports were changed every three or five seconds to save some screenshots. There existed a schedule of visible 3D tiles due to the limited GPU memory. I guess that was the reason why sometimes the WebGL error might happen. Due to the long-term running of the program, the main memory seemed full, the computer was nearly frozen, and the error might occur more easily? When I stopped the program, everything went well again.

So I guess the full main memory issue is related to the browser’s recording of information about the downloading. How can I avoid it or how can I use such kind of application of Cesium on the browser? In addition, I may also do a control experiment to check the situation when no screenshots are saved.

Best regards,

Eric.