Proper try of Cesium creation, error catching, cross browser compatibility and developer errors.

I am currently working on a GIS project hat has to be cross browser, mobile, multiplatform and omnipotent.

Cesium does not work without WebGL, on some older browser and other minor exceptions, but i have to catch them.

I decided to swich to OpenLayers when Cesium can’t be an option, OL works well on pretty everything.

As for now, I have a try catch for new Cesium.Viewer, and the catch starts OpenLayers, which worked pretty great until recently, when i started getting Cesium “out of memory” error.

Cesium docs on Developer Error stands: should never be caught; instead the calling code should strive not to generate it.

Well how do get around to that striving ?

Is there any reliable way of checknig whether Cesium will fire up properly, or do i have to try catch every single method i am calling to be sure it won’t crash out?

I’ll apricieate any response, i’m kind of banging rocks together here.

Thanks in advance.



In my Cesium-based app (it has a 2D fallback like yours, Leaflet in my case), we use this check to determine if WebGL is supported:

I haven’t seen the Cesium.Viewer fail to be constructed after passing this check, although I’m sure some horribly broken WebGL implementation somewhere might fail in that way.

We also catch render loop errors and switch to 2D:

Out of memory errors can be pretty hard to recover from, though. If Cesium is crashing due to being out of memory, you’ll probably need to figure out how to reduce your memory usage, rather than attempt to catch it and recover.


Catching render loop error will be helpful here.

Thanks Kevin!