Expected width to be greater than 0, actual value was 0 Error

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

I tried to publish the data in CityGML format to the web using 3DcityDB and 3DcityDBwebclient. Using 3DImporterExporter tool I successfully convert the data to KML/COLLDA format. By using Add layer option in 3Dwebclient page (index.html) I published the Collada-Json file to create scene URL. Here I am facing some problems:

When I load my entire data after some time I encounter the error "Render has stopped" with the following error, if I load partial data it is working fine.

Kindly help me to fix this.

An error occurred while rendering. Rendering has stopped.

DeveloperError: Expected width to be greater than 0, actual value was 0 Error

    at new DeveloperError (http://localhost:8000/ThirdParty/Cesium/Cesium.js:540:19)

    at Function.Check.typeOf.number.greaterThan (http://localhost:8000/ThirdParty/Cesium/Cesium.js:699:19)

    at new Texture (http://localhost:8000/ThirdParty/Cesium/Cesium.js:88180:29)

    at createTextures (http://localhost:8000/ThirdParty/Cesium/Cesium.js:208711:36)

    at updateFramebuffers (http://localhost:8000/ThirdParty/Cesium/Cesium.js:208757:13)

    at GlobeDepth.update (http://localhost:8000/ThirdParty/Cesium/Cesium.js:208838:9)

    at updateAndClearFramebuffers (http://localhost:8000/ThirdParty/Cesium/Cesium.js:224894:31)

    at executeCommandsInViewport (http://localhost:8000/ThirdParty/Cesium/Cesium.js:224719:17)

    at updateAndExecuteCommands (http://localhost:8000/ThirdParty/Cesium/Cesium.js:224575:13)

    at render (http://localhost:8000/ThirdParty/Cesium/Cesium.js:225111:9)

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

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

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

See my answer here: https://groups.google.com/d/msg/cesium-dev/1QqvUw12ado/3TFSMADGGQAJ

I am unable to access this link, can you help me

@GeorgeZZW The error “Expected width to be greater than 0, actual value was 0” can have many reasons. (From my experience, it usually means that some GL context was lost due to some rendering error or an out-of-memory situation, but there are more). It is very unlikely that the reason in your case is the same as it has been in this thread 5 years ago. Maybe you can open a new thread with detailed information about your setup (including your CesiumJS version), and preferably a Cesium Sandcastle where the error appears.

Hi, i found this mistake too. Could you fix it?
There is a demo, Click the “testButton”, then click the close button on the upper right corner of the dialog to close it. Repeat this operation 16 times, and the error shown.

Demo:

Admittedly, I was a bit surprised to see that this happens after clicking exactly 16 times. I wonder why it is exactly 16 (apparently, not depending on the environment of browser/OS/GPU…). But from that example, this looks like a clear-cut bug, i.e. a memory leak. So this specific case may warrant some further investigation.

This is a problem I have discovered that always occurs. Other situations can also cause it, for example, when using a WebGL video player, repeatedly turning the player on and off can also lead to this error in the Cesium viewer. In conclusion, when there are multiple WebGL elements on a page and the initialization and destruction operations are executed multiple times, this error is very likely to occur.

There are some details (in fact, many details) that have to be investigated. But the problem description (for CesiumJS as well as for any other WebGL-based application that exposes this behavior) sounds like a clear cases of a memory leak.

A pseudocode(!!!) loop like

while (true) {
    const viewer = new Cesium.Viewer("cesiumContainer");
    waitUntilSomeStuffIsLoaded();
    viewer.destroy();
}

should run forever, and never use more memory than during a single creation of the viewer, and of course, should never bail out with a lost GL context (which is what leads to the error message in the title here).

Or to put it that way: I’m pretty sure that viewer.destroy() is missing something, and not destroying some texture that should be destroyed by this call.

(Analyzing which texture that is, and how it could be destroyed, is the more time-consuming part here…)

OK, I was just made aware that this was also brought up in DeveloperError: Expected width to be greater than 0, actual value was 0 · Issue #12517 · CesiumGS/cesium · GitHub , and the linked issue ( webgl context is not released when destroy viewer! · Issue #11533 · CesiumGS/cesium · GitHub ) suggests that this is indeed a missing cleanup step when destroying the viewer.

The issue #12517 on GitHub was raised by me :joy:. Could you solve this kind of problem?

I just wanted to have that connection. When someone finds this forum thread (for example, via a websearch), then it could be helpful to find possible solutions or workarounds that have been posted in the issue report.

I think that there currently is no clear solution, though. One part of the problem is webgl context is not released when destroy viewer! · Issue #11533 · CesiumGS/cesium · GitHub , which sounds like it could be easy to fix (like ~“just add something.release() at the right place”), but I have not yet investigated the details…

Thanks, got it. Please keep me updated if there’s progress on this!

Hi, I found that using a third-party library can solve the problem of repeatedly creating and destroying viewer instances, but I don’t know the principle, and i’m not sure if using this library will have any unintended consequences. Would you mind reviewing this?

Here are the key codes and demos:

// step 1  "https://github.com/plotly/plotly.js"
<script src="https://unpkg.com/virtual-webgl@1.0.6/src/virtual-webgl.js"></script>

let viewer = new Cesium.Viewer(cesiumContainer, {
        contextOptions: {
           // step 2
           requestWebgl1: true,
       }
});

// Using the above method, no errors will be reported even after hundreds of executions

There is a demo:

@Willian I can not quickly give profound advice here.

From quickly looking at the description at GitHub - greggman/virtual-webgl: Virtualize WebGL Contexts it looks interesting, but am not sure whether it is “the way to go” here. It looks like it could be a workaround that may help to avoid the issue, but it might come at a cost. First of all, there is that requestWebgl1:true part that may have certain implications, like certain features not working reliably, or decreased performance. The performance implications of this “virtualization” in general are not clear to me. (I’d have to look very closely at what this library is doing under the hood - and won’t claim that I’d immediately understand that :grimacing: ). And eventually, I don’t know whether it really solves the issue, or just ~“avoids” it to a certain degree. (For example - just as a wild guess - you might receive the same error message when you create and destroy the viewer not 16 times, but more times (like 16x16 or so…))

tl:dr: I think it would be much better to actually fix webgl context is not released when destroy viewer! · Issue #11533 · CesiumGS/cesium · GitHub (but haven’t looked at the details or possible timelines for that…)

Following up on the WebGL context release issue - would it be possible to expedite a fix? We’re facing serious implementation challenges due to this.

Additionally, before the error occurs, the console always shows the warning:
“WARNING: Too many active WebGL contexts. Oldest context will be lost.”
Can be easily simulated using:

const canvas = viewer.canvas
const gl = canvas.getContext('webgl2')
gl.getExtension('WEBGL_lose_context').loseContext()  

This has been one of ~100 open tabs for a few days now, and to not leave this unanswered

I personally do not set the priorities for bugfixes and features. But given that …

  • the error is fatal, in that it is not ~“a small rendering glitch”, but really breaks the whole application
  • the conditions and reasons for when and why the error occurs seem to be somewhat clear (unless I’m overlooking something)
  • the fix might be easy in terms of “number of lines of code that have to be changed” (it’s not a fundamental design flaw that has to be refactored out, but most likely consists of inserting some destroy() call at the right place)

I agree that this should be considered rather sooner than later. I’ll bring it up again, and in doubt, I will try to allocate some time to investigate this. The difficult (and unpredictable) part is: Where exactly in the code does this (hopefully) ‘easy fix’ have to be inserted? So I can hardly make promises at this point.

Understood. I’m looking forward to your official fix. Please keep me updated when there’s progress on this issue.

Usually, we try to keep the connection: When an issue is reported in the forum, and then escalated into an issue in the CesiumJS repo, the issue description contains a link to the forum thread. Similarly, subsequent forum threads (where the same issue was brought up) are linked to the issue description, and vice versa.

The goal is to make sure that when the issue is fixed, there can be a response in the forum thread, saying when and how the issue was fixed, to make sure that people who stumble over the forum thread can find the solution (e.g. the version number that contains the fix).

In this case, the connection was not yet there. I added a comment at webgl context is not released when destroy viewer! · Issue #11533 · CesiumGS/cesium · GitHub for that.

Thanks. I’ll follow the issue closely.