cesium icon indicating copy to clipboard operation
cesium copied to clipboard

Detect multiple instances of `cesium` or `@cesium/engine`

Open jjspace opened this issue 11 months ago • 0 comments

With the current architecture of CesiumJS it's not possible to run an application with multiple versions of CesiumJS on the page. This is due to a few global/shared objects that we expect to exist and get initialized. Specifically ContextLimit seems to come up often.

This tends to happen more when using a build system like Vite or Webpack that is perfectly happy to bundle different versions by renaming classes (like Scene1 and Scene2). When this happens calling some parts of the Cesium API will reference one version of an object that has been initialized correctly and other parts calling a version that has not been initialized. This causes an error that looks something like:

DeveloperError: renderState.lineWidth is out of range.  Check minimumAliasedLineWidth and maximumAliasedLineWidth.

(community forum posts 1, 2, 3)

We should figure out if it's possible to detect this and provide a more developer friendly error that they've included 2 versions of Cesium somehow

There's also probably work we could do to re-architect parts of cesium and/or change dependency tags to better prevent this. At the very least this issue can act as a place to track when this error pops up.

jjspace avatar May 09 '25 14:05 jjspace