Recovering after crash

I'm trying to get Cesium to gracefully recover after a crash. I've got showRenderLoopErrors set to false, and I'm listening for the renderError event. When it happens, I clear all the drawings and all data sources (entities.removeAll, dataSources.removeAll). I reset the camera back to the "default earth" view. Then I resume rendering by setting useDefaultRenderLoop back to true. This allows me to continue using the viewer. However, it normally fails if I try to create entities again.

Is there some way I can completely reset the viewer back to its initial state so I can completely recover from the crash? For example, completely emptying the render queue, etc? There must be a way to clear the internal state of the viewer after it has become corrupted so I can create entities again. Any advice on how to go about attempting a crash recovery?

My next avenue will be to load a new viewer upon an error and start again, but obviously this is clunkier and less desirable than simply resetting the internal state of the existing viewer. Thanks in advance.

Why is your application crashing? It sounds like the better answer is to fix the crash. You should not be getting errors on a regular basis like that.

That being said, if you insist on using this strategy, you should destroy the old Viewer and recreate a new instance. It’s the only way be sure to start fresh.