Hi,
I have a problem with the Measure SDK. Here, I want to ask for help in that, but also or alternatively for away not needing to use the widget, in order to be able to design the experience ourselves?
Is there a way not to use the widget?
We are calling the SDK as stated in the docs. We are using vite for our builds in the documented way. In development the SDK works alright (except for CSS / styling issues), when we build for production the SDK will cause the renderer to crash. Is there anything anyone can think of?
DeveloperError: renderState.lineWidth is out of range. Check minimumAliasedLineWidth and maximumAliasedLineWidth.
Error
at new DeveloperError (http://localhost:3080/assets/index-CIBv_jyc.js:319235:11)
at new RenderState (http://localhost:3080/assets/index-CIBv_jyc.js:335108:11)
at RenderState.fromCache (http://localhost:3080/assets/index-CIBv_jyc.js:335240:16)
at PointPrimitiveCollection.update (http://localhost:3080/assets/index-CIBv_jyc.js:424331:36)
at PrimitiveCollection.update (http://localhost:3080/assets/index-CIBv_jyc.js:424658:20)
at PrimitiveCollection$1.update (http://localhost:3080/assets/index-CIBv_jyc.js:162176:20)
at updateAndRenderPrimitives (http://localhost:3080/assets/index-CIBv_jyc.js:235133:21)
at executeCommandsInViewport (http://localhost:3080/assets/index-CIBv_jyc.js:234984:3)
at Scene$4.updateAndExecuteCommands (http://localhost:3080/assets/index-CIBv_jyc.js:234806:5)
at render (http://localhost:3080/assets/index-CIBv_jyc.js:235553:9)
The RenderState as constructed from PointPrimitiveCollection uses the default value of lineWidth = 1.0, so the error indicates that the ContextLimits object was not populated correctly.
ContextLimits is a somewhat unconventional class. It is possible it doesn’t work well with the vite build system. I am checking internally with people who have more experience with vite.
Based on the error message, it looks like you may be loading more than one version of CesiumJS, so there could be conflicts between multiple versions of ContextLimits.
Can you clarify how you are installing and building the app? Are you loading the packages via npm or downloading the .zip files?
Via the zips in a monorepo kind of setting (turbo, pnpm).
I can attempt to check whether cesium is emitted twice. It’s just weird that this would differ in prod builds.
This is our (excerpt) vite config which we have adapted from numerous sources. TBH our build pipeline was hacked a bit defensively, as it wasn’t quite straightforward from documentation.
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { viteStaticCopy } from 'vite-plugin-static-copy'
import tailwindcss from 'tailwindcss'
import { TanStackRouterVite } from '@tanstack/router-plugin/vite'
import { visualizer } from 'rollup-plugin-visualizer'
// https://github.com/CesiumGS/cesium-vite-example
// const cesiumSource = "node_modules/cesium/Build/Cesium";
// This is the base url for static files that CesiumJS needs to load.
// Set to an empty string to place the files at the site's root path
const cesiumBaseUrl = 'cesiumStatic'
// https://vitejs.dev/config/
export default defineConfig({
define: {
// Define relative base path in cesium for loading assets
// https://vitejs.dev/config/shared-options.html#define
CESIUM_BASE_URL: JSON.stringify(`/${cesiumBaseUrl}`)
},
build: {
minify: true,
rollupOptions: {
output: {
chunkFileNames: 'assets/[name]-[hash].js',
manualChunks: {
}
}
}
},
optimizeDeps: {
exclude: ['cesium']
},
plugins: [
TanStackRouterVite(),
react(),
viteStaticCopy({
targets: [
{ src: 'node_modules/@cesium/engine/Build/Workers', dest: cesiumBaseUrl },
{ src: 'node_modules/@cesium/engine/Build/ThirdParty', dest: cesiumBaseUrl },
{ src: 'node_modules/@cesium/engine/Build/Widgets', dest: cesiumBaseUrl },
{ src: 'node_modules/@cesium/engine/Source/Assets', dest: cesiumBaseUrl }
]
}),
visualizer({
// emitFile: true,
filename: 'bundle-stats.html'
})
],
css: {
postcss: {
plugins: [
tailwindcss()
]
}
},
server: {
proxy: {
}
}
})
I have a first indication that this is true. The import paths are somewhat fiddly, as the SDK requires a peer dependency of @cesium/engine 11 but everything else is at 12. This is a bit hard to fix, as we do not like patching the downloaded SDK. But very likely we need to.
I haven’t quite concluded with a fix, yet, and will keep you posted what our solution will be.
BTW, I was able to confirm this via vite bundle stats.
Following up on your post and discussion with @jjhembd, I wanted to weigh in and see if you are using the latest version of ion SDK 1.123.1, which I believe updated all @cesium/engine dependencies to 12.0.1. If you are already on ion SDK 1.123.1 and seeing something different please let us know and we would be happy to investigate further.