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

105.1 Have a Fatal Error on 'https://sandcastle.cesium.com/?src=Cesium Inspector.html' #11278

Closed CHENJIAMIAN closed 1 year ago

CHENJIAMIAN commented 1 year ago

105.1 Have a Fatal Error on 'https://sandcastle.cesium.com/?src=Cesium Inspector.html'

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title></title>
    <link
      href="https://cesium.com/downloads/cesiumjs/releases/1.105.1/Build/Cesium/Widgets/widgets.css"
      rel="stylesheet"
    />
  </head>
  <body>
    <div id="cesiumContainer" class="fullSize"></div>

    <script type="module">
      window.CESIUM_BASE_URL =
        "https://cesium.com/downloads/cesiumjs/releases/1.105.1/Build/Cesium";

      import * as Cesium from "https://esm.sh/cesium@1.105.1";

      const viewer = new Cesium.Viewer("cesiumContainer", {
        terrain: Cesium.Terrain.fromWorldTerrain(),
      });

      const scene = viewer.scene;
      scene.globe.depthTestAgainstTerrain = true;

      //Add Cesium Inspector
      viewer.extend(Cesium.viewerCesiumInspectorMixin);

      //Add Primitives
      scene.primitives.add(
        new Cesium.Primitive({
          geometryInstances: new Cesium.GeometryInstance({
            geometry: Cesium.BoxGeometry.fromDimensions({
              vertexFormat: Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
              dimensions: new Cesium.Cartesian3(400000.0, 300000.0, 500000.0),
            }),
            modelMatrix: Cesium.Matrix4.multiplyByTranslation(
              Cesium.Transforms.eastNorthUpToFixedFrame(
                Cesium.Cartesian3.fromDegrees(-105.0, 45.0)
              ),
              new Cesium.Cartesian3(0.0, 0.0, 250000),
              new Cesium.Matrix4()
            ),
            attributes: {
              color: Cesium.ColorGeometryInstanceAttribute.fromColor(
                Cesium.Color.RED.withAlpha(0.5)
              ),
            },
          }),
          appearance: new Cesium.PerInstanceColorAppearance({
            closed: true,
          }),
        })
      );

      scene.primitives.add(
        new Cesium.Primitive({
          geometryInstances: new Cesium.GeometryInstance({
            geometry: new Cesium.RectangleGeometry({
              rectangle: Cesium.Rectangle.fromDegrees(
                -100.0,
                30.0,
                -93.0,
                37.0
              ),
              height: 100000,
              vertexFormat: Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
            }),
            attributes: {
              color: Cesium.ColorGeometryInstanceAttribute.fromColor(
                Cesium.Color.BLUE
              ),
            },
          }),
          appearance: new Cesium.PerInstanceColorAppearance(),
        })
      );

      const billboards = scene.primitives.add(new Cesium.BillboardCollection());
      billboards.add({
        position: Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883, 150000),
        image: "../images/Cesium_Logo_overlay.png",
      });
    </script>
  </body>
</html>

image


105.0 is normal and there are no errors.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title></title>
    <link
      href="https://cesium.com/downloads/cesiumjs/releases/1.105/Build/Cesium/Widgets/widgets.css"
      rel="stylesheet"
    />
  </head>
  <body>
    <div id="cesiumContainer" class="fullSize"></div>

    <script type="module">
      window.CESIUM_BASE_URL =
        "https://cesium.com/downloads/cesiumjs/releases/1.105/Build/Cesium";

      import * as Cesium from "https://esm.sh/cesium@1.105.0";

      const viewer = new Cesium.Viewer("cesiumContainer", {
        terrain: Cesium.Terrain.fromWorldTerrain(),
      });

      const scene = viewer.scene;
      scene.globe.depthTestAgainstTerrain = true;

      //Add Cesium Inspector
      viewer.extend(Cesium.viewerCesiumInspectorMixin);

      //Add Primitives
      scene.primitives.add(
        new Cesium.Primitive({
          geometryInstances: new Cesium.GeometryInstance({
            geometry: Cesium.BoxGeometry.fromDimensions({
              vertexFormat: Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
              dimensions: new Cesium.Cartesian3(400000.0, 300000.0, 500000.0),
            }),
            modelMatrix: Cesium.Matrix4.multiplyByTranslation(
              Cesium.Transforms.eastNorthUpToFixedFrame(
                Cesium.Cartesian3.fromDegrees(-105.0, 45.0)
              ),
              new Cesium.Cartesian3(0.0, 0.0, 250000),
              new Cesium.Matrix4()
            ),
            attributes: {
              color: Cesium.ColorGeometryInstanceAttribute.fromColor(
                Cesium.Color.RED.withAlpha(0.5)
              ),
            },
          }),
          appearance: new Cesium.PerInstanceColorAppearance({
            closed: true,
          }),
        })
      );

      scene.primitives.add(
        new Cesium.Primitive({
          geometryInstances: new Cesium.GeometryInstance({
            geometry: new Cesium.RectangleGeometry({
              rectangle: Cesium.Rectangle.fromDegrees(
                -100.0,
                30.0,
                -93.0,
                37.0
              ),
              height: 100000,
              vertexFormat: Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
            }),
            attributes: {
              color: Cesium.ColorGeometryInstanceAttribute.fromColor(
                Cesium.Color.BLUE
              ),
            },
          }),
          appearance: new Cesium.PerInstanceColorAppearance(),
        })
      );

      const billboards = scene.primitives.add(new Cesium.BillboardCollection());
      billboards.add({
        position: Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883, 150000),
        image: "../images/Cesium_Logo_overlay.png",
      });
    </script>
  </body>
</html>
ggetz commented 1 year ago

Hi @CHENJIAMIAN,

I'm not able to reproduce the error on https://sandcastle.cesium.com. Is there any other steps I need to take to reproduce? If not, would you mind sharing system details, and visiting webglreport.com to take a screenshot of your results?

It would be odd that this error started occurring in 1.105.1, as there were no renderer changes since 1.105.

CHENJIAMIAN commented 1 year ago

live demo to reproduce

my webglreport.com screenshot webglreport com__v=2

CHENJIAMIAN commented 1 year ago

I'm also not able to reproduce the error on https://sandcastle.cesium.com/.

easternmotors commented 1 year ago

I am having a similar error once updating from @cesium/engine@2.3.0 to @cesium/engine@2.4.0 when just trying to load a Globe. I also can't reproduce my error in a Sandcastle example. Does Sandcastle use the built NPM dependency or does it reference the files using relative paths?

Note: Downgrading from @cesium/engine@2.4.0 to @cesium/engine@2.3.0 fixes the issue for me. I wouldn't expect this to be a breaking change with a cesium patch version/@cesium/engine minor version.

tinco commented 1 year ago

I had similar error upgrading to 105.1. I noticed in our yarn.lock file that we were loading both @cesium/engine@2.3.0 and @cesium/engine@2.4.0 at the same time and it was causing all sorts of problems.

I'm not sure how it's possible, but this is in our yarn.lock:

"@cesium/widgets@2.2.0":
  version "2.2.0"
  resolved "https://registry.yarnpkg.com/@cesium/widgets/-/widgets-2.2.0.tgz#1b7d3940b6de509ed86a3e51a5c1caf288dd9f79"
  integrity sha512-t15V02J5cJcq2GxJlWy6a5zT1P+kw7cGDOAKbWb/CMNXxc/bxl2FeOoX6PMT+FuPNxREkR+xMxtXig44hvbRJQ==
  dependencies:
    "@cesium/engine" "2.3.0"

But if I look at the package.json on github tag 1.105.1 it's clearly depending on 2.4.0:

https://github.com/CesiumGS/cesium/blob/1.105.1/packages/widgets/package.json

Actually it becomes a bit clearer here:

https://www.npmjs.com/package/@cesium/widgets?activeTab=readme

Version 2.2.0 was released 11 days ago.

So I think the problem is that the widgets version wasn't bumped to incorporate the new engine version dependency.

ggetz commented 1 year ago

Got it, will bump the widgets version. A bit strange that this is causing a rendering error though.

CHENJIAMIAN commented 1 year ago

The context of @cesium/engine@2.3.0 overlaps with the context of @cesium/engine@2.4.0, causing this strange error.

Call stack is as follows:

  1. @cesium/engine@2.4.0/Scene
  2. @cesium/engine@2.4.0/Context
  3. @cesium/engine@2.3.0/ContextLimits
  4. @cesium/engine@2.3.0/ContextLimits.maximumVertexTextureImageUnits === 0
  5. throw new RuntimeError("Vertex texture fetch support is required to render primitives with per-instance attributes. The maximum number of vertex texture image units must be greater than zero.");
CHENJIAMIAN commented 1 year ago

I think I said it the other way around, It doesn't prevent us from understanding the reason, haha. The bolded part is "2.4". The ones without bold are 2.3.


An error occurred while rendering. Rendering has stopped. RuntimeError: Vertex texture fetch support is required to render primitives with per-instance attributes. The maximum number of vertex texture image units must be greater than zero. Error at new RuntimeError (https://esm.sh/v120/@cesium/engine@2.4.0/es2022/engine.development.mjs:2308:11) at Primitive.update (https://esm.sh/v120/@cesium/engine@2.4.0/es2022/engine.development.mjs:40747:13) at PrimitiveCollection.update (https://esm.sh/v120/@cesium/engine@2.3.0/es2022/engine.development.mjs:127695:19) at updateAndRenderPrimitives (https://esm.sh/v120/@cesium/engine@2.3.0/es2022/engine.development.mjs:190614:21) at executeCommandsInViewport (https://esm.sh/v120/@cesium/engine@2.3.0/es2022/engine.development.mjs:190466:3) at Scene4.updateAndExecuteCommands (https://esm.sh/v120/@cesium/engine@2.3.0/es2022/engine.development.mjs:190284:5) at render (https://esm.sh/v120/@cesium/engine@2.3.0/es2022/engine.development.mjs:190922:9) at tryAndCatchError (https://esm.sh/v120/@cesium/engine@2.3.0/es2022/engine.development.mjs:190936:5) at Scene4.render (https://esm.sh/v120/@cesium/engine@2.3.0/es2022/engine.development.mjs:190988:5) at CesiumWidget.render (https://esm.sh/v120/@cesium/engine@2.3.0/es2022/engine.development.mjs:192372:17)


yongjias commented 1 year ago

Had similar issue in 1.105.1 only.

ggetz commented 1 year ago

Thanks @CHENJIAMIAN, I have published @cesium/widgets@2.3.0 and cesium@1.105.2 with updated dependencies. Can you please verify that fixes the issue?

CHENJIAMIAN commented 1 year ago

The issue has been resolved.

I have additional questions about https://cesium.com/downloads/cesiumjs/releases/1.105.2/Build/Cesium/Widgets/widgets.css which is currently showing a 404 error. There are also no static resources under https://cesium.com/downloads/cesiumjs/releases/1.105.2/Build/Cesium. such as https://cesium.com/downloads/cesiumjs/releases/1.105.2/Build/Cesium/Assets/approximateTerrainHeights.json 404


I am using them as a CDN.

ggetz commented 1 year ago

Thanks @CHENJIAMIAN. 1.105.2 was an npm only release, so we did not deploy to the CDN. The CDN version is also pre-built, so there are no dependencies to resolve.

Southjor commented 1 year ago

这个问题再最新版(1.106.0)还是存在!

image

image

但是,奇怪的是,npm 引入方式有问题,在 sandcastle 中不能复现。

sandcastle 示例