CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
13.01k stars 3.51k forks source link

Error constructing Cesium Widget #11350

Closed artzers closed 1 year ago

artzers commented 1 year ago

I want to develop app with cesium on Ubuntu deployed in Vmware workstation, or arm Linux on embedded development board. I used chrome and firefox to open https://sandcastle.cesium.com/, and get the error information. I opened chrome://gpu/ and found: WebGL: Hardware accelerated WebGL2: Hardware accelerated The webgl and webgl2 were both available and it is strange that I cannot run cesium normally.

The detailed information below.

Error constructing CesiumWidget. Visit http://get.webgl.org to verify that your web browser and hardware support WebGL. Consider trying a different web browser or updating your video drivers. Detailed error information is below: RuntimeError: The browser supports WebGL, but initialization failed. RuntimeError@https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:13371:13 getWebGLContext@https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:182791:13 Context@https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:182543:92 Scene4@https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:229577:21 CesiumWidget@https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:238332:21 Viewer@https://sandcastle.cesium.com/CesiumUnminified/Cesium.js:250524:26 window.startup@https://sandcastle.cesium.com/templates/bucket.html line 681 > injectedScript:5:16 @https://sandcastle.cesium.com/templates/bucket.html line 681 > injectedScript:11:12 loadScript@https://sandcastle.cesium.com/CesiumSandcastle.js:681:24

ggetz commented 1 year ago

Hi @artzers, thanks for the report. Could you please visit webglreport.com and take a screenshot of your results?

artzers commented 1 year ago

@ggetz It shows × This browser supports WebGL 2, but it is disabled or unavailable. I did not found how to enable webgl2 for chrome and firefox in Ubuntu for Vmware workstation. I have tried the hardware acceleration, ignore-gpu-list, and none of them worked. Finally I found a solution for my cesium web application. Cesium 1.95 was deployed in my web server application in Ubuntu for Vmware workstation. It worked. Cesium 1.104 and 1.106 did not work. Maybe Cesium 1.95 was fully supported by Webgl 1.0 and webgl 2.0 was not needed.

ggetz commented 1 year ago

Thanks @artzers!

In 1.102, the default changed from using a WebGL 1 context to using a WebGL2 context for rendering.

Going forward, CesiumJS attempt to detect if WebGL 2 is supported and if not it falls back to WebGL1. However, you can manually use WebGL 1 with the following configuration.

const viewer = new Viewer("cesiumContainer", {
  contextOptions: {
    requestWebgl1: true,
  },
});

Hope that helps!