When I create and destroy viewer frequently, cesium throw error

1. A concise explanation of the problem you're experiencing.

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

viewer = new Cesium.Viewer(`${this.id}cesiumContainer`, {
          ...
        })

  viewer.destroy()

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I have many pages to switch. To ensure performance, I leave only the current page, and the other pages are destroyed.so when I leave this page , I destroy viewer. when I come to page ,I create it .specially, the page is configured, there may be several earth.

4. The Cesium version you're using, your operating system and browser.
the lastest chrome

1 Like

What error does it throw?

I believe this may be an issue with the browser not clearing out WebGL contexts completely. Check out this thread for more info:

https://github.com/AnalyticalGraphicsInc/cesium/issues/5462

A better approach might be to save the WebGL context and re-use it.

1 Like