Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing a polygon-Entity's material and show members crashes StaticGeometryColorBatch under certain conditions #3061

Closed
nmschulte opened this issue Oct 7, 2015 · 13 comments

Comments

@nmschulte
Copy link
Contributor

(Found in v1.12, exists in v1.14.)

While working on a project that integrates Cesium and Angular, I ran across this interesting issue that was causing Cesium to crash. I've created a use-case that reproduces the error, though as the issue appears to be a race condition internally to Cesium I am uncertain exactly the conditions.

Regardless, the error is reproducible 100% in my private use-case, and given enough time the example use-case reproduces the error too. I had lost hope in creating an example use-case, and right as I was going to close the browser and lose the work, it crashed:

2015-10-07-171252_1896x1232_scrot

I know for certain that polygon Entitys are affected, but perhaps others are as well; I didn't test them.

The issue appears to stem from some interaction with updating the show member and the material member of Entitiys (*Graphics' Propertys) in the render loop.

Of note is that I am updating the heirarchy member at the same time as the material (and in fact, in my real use case, these three properties (heirarchy, material, show) are always all updated at the same time (in the same JS tick/turn)); I kept it here because it was in my private use-case and may be important.

As well, my private use-case fails only when the 'material' ("fillColor") changes (I set the member every time, but it isn't always a new value like in the example use-case).

Finally, in my private use-case, it fails with this output from the following code (look at the timing; this is poked by Angular/$digest, but I believe it is all in a single JS tick/turn):

function (entity, coordinates, fillColor, show) {
    (function() {
        console.log(entity.id + ' - ' + entity.show + ' - ' + entity.polygon.material.color.getValue().equals(fillColor))
        entity.polygon.hierarchy = createPositionsFromArray(coordinates);
        entity.polygon.material = fillColor;
    }());

    entity.show = show;
}
2015-10-07 17:39:24.255    57d8e305-ea19-4125-8f30-fa44ef2605fb_polygon - true - true
2015-10-07 17:39:24.819    57d8e305-ea19-4125-8f30-fa44ef2605fb_polygon - false - true
2015-10-07 17:39:24.899    57d8e305-ea19-4125-8f30-fa44ef2605fb_polygon - false - false

This is the code I added to the Polygon Sandcastle (http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Polygon.html&label=Geometries)

function changeMaterial() {
    orangePolygon.polygon.heirarchy = Cesium.Cartesian3.fromDegreesArrayHeights([-108.0, 25.0, 100000,
                                                               -100.0, 25.0, 100000,
                                                               -100.0, 30.0, 100000,
                                                               -108.0, 30.0, 300000]);

        orangePolygon.polygon.material = Cesium.Color.fromRandom();
}

function changeShow() {
    orangePolygon.show = (Math.random() >= 0.5);
}

setInterval(changeMaterial, 50);
setInterval(changeShow, 100);
@nmschulte
Copy link
Contributor Author

More information: when StaticGeometryColorBatch crashes, the _hashes property of the geometry member has undefined for the entity that is causing problems (and the _array's length is one less than it should be).

This is a textual copy of the error:

An error occurred while rendering. Rendering has stopped.
TypeError: Cannot read property 'id' of undefined
TypeError: Cannot read property 'id' of undefined
    at Batch.updateShows (http://cesiumjs.org/Cesium/Source/DataSources/StaticGeometryColorBatch.js:180:58)
    at Batch.update (http://cesiumjs.org/Cesium/Source/DataSources/StaticGeometryColorBatch.js:165:18)
    at StaticGeometryColorBatch.update (http://cesiumjs.org/Cesium/Source/DataSources/StaticGeometryColorBatch.js:259:42)
    at GeometryVisualizer.update (http://cesiumjs.org/Cesium/Source/DataSources/GeometryVisualizer.js:228:36)
    at DataSourceDisplay.update (http://cesiumjs.org/Cesium/Source/DataSources/DataSourceDisplay.js:243:37)
    at Viewer._onTick (http://cesiumjs.org/Cesium/Source/Widgets/Viewer/Viewer.js:1317:49)
    at Event.raiseEvent (http://cesiumjs.org/Cesium/Source/Core/Event.js:147:30)
    at Clock.tick (http://cesiumjs.org/Cesium/Source/Core/Clock.js:204:21)
    at CesiumWidget.render (http://cesiumjs.org/Cesium/Source/Widgets/CesiumWidget/CesiumWidget.js:661:43)
    at render (http://cesiumjs.org/Cesium/Source/Widgets/CesiumWidget/CesiumWidget.js:68:32)

@nmschulte nmschulte changed the title Changing a polygon Entity's material and show members crashes StaticGeometryColorBatch under certain conditions Changing a polygon-Entity's material and show members crashes StaticGeometryColorBatch under certain conditions Oct 7, 2015
@hpinkos
Copy link
Contributor

hpinkos commented Dec 23, 2015

@nmschulte Sorry no one responded when you reported this

Does this still crash for you? When I ran the sandcastle example you posted, it caused the polygon to flicker and change colors, but it never caused a crash. Thanks!

@nmschulte
Copy link
Contributor Author

@hpinkos I just ran the test-case again and Cesium still crashes after a short run (just a few minutes).

In Chromium (Google Chrome), I receive the same error as before.

I tested in Iceweasel (Mozilla Firefox), and I receive this error after a short while:
2015-12-23-131332_1920x1044_scrot

@hpinkos
Copy link
Contributor

hpinkos commented Dec 23, 2015

okay, thanks for checking!

@nmschulte
Copy link
Contributor Author

I tried this in Google Chrome from a Windows 8 virtual-machine (VirtualBox) and received the error there too:

2015-12-23-141259_1920x1044_scrot

@nmschulte nmschulte changed the title Changing a polygon-Entity's material and show members crashes StaticGeometryColorBatch under certain conditions Changing a polygon-Entity's material and show members crashes StaticGeometryColorBatch under certain conditions Dec 23, 2015
@adventurist
Copy link

Greetings! Did anyone ever follow up on this? I don't have the exact same use case, but I am triggering this error in an app where hovering over items in a legend triggers the setting of a material property on a large number of entities.

@mramato
Copy link
Contributor

mramato commented Oct 18, 2016

@nmschulte I can not reproduce this bug with the sampled code provided in the latest version of Cesium, I'm going to close this because we have definitely fixed a similar issue since 1.14 we released. If you are still having problems, please reopen this with some additional details on reproducing.

@adventurist I'm not sure your problem is the same as @nmschulte. If you have a reproducible test case that we can use to debug your issue, please open a new issue. Otherwise, I would recommend asking on the forum first and seeing if anyone there can help.

@mramato mramato closed this as completed Oct 18, 2016
@nmschulte
Copy link
Contributor Author

@mramato I'm unable to reproduce the issue with my given test case (I no longer have access to the private use-case).

However, I did notice some funky behavior when using the "focus"/"inspect" tool; I managed to get things into a state such that, if the code above hid the object, Cesium would render some other fixed representation (like, it had cached one of the states and would always show that). I can make a new bug report with a video of this if you like.

@mramato
Copy link
Contributor

mramato commented Oct 18, 2016

I can make a new bug report with a video of this if you like.

If it's easily reproducible and clearly incorrect, then yes, a new issue would be great. Thanks.

@bflood-agi
Copy link
Contributor

bflood-agi commented May 3, 2018

Hi all,

We have a widget for editing a polyline, and I've just encountered this same error message, except that, instead of originating from StaticGeometryColorBatch.update, the error occurs in StaticGeometryPerMaterialBatch.update. I did a little digging, and the call to this.attributes.get(instance.id.id); at line 253 of StaticGeometryPerMaterialBatch.js is what's causing the issue. instance at line 251 is coming back undefined. There's an item (only one) in this.geometry, but its ID doesn't match the ID of updater.entity.

I'm working on creating a reproducible example, as the part of our code this is happening in is a tangled mess. Hopefully that in itself will uncover some clues, but in the meantime, any direction on how I might continue my search would be much appreciated. Thanks!

@nmschulte
Copy link
Contributor Author

I just ran my sample code again in the Geometries sandcastle demo and received the same TypeError noted in my initial investigation. This is without making any selection, though it happens when entities are selected too. #4445 still exists; some sort of race regarding material update, show/hide update, and "selection indicator" (user input or some internal update/output logic).

2018_05_04-09_02_46-1920x1153

@hpinkos hpinkos reopened this May 4, 2018
@hpinkos
Copy link
Contributor

hpinkos commented May 4, 2018

Thanks @bflood-agi @nmschulte, we'll try to look into this soon

@hpinkos
Copy link
Contributor

hpinkos commented May 7, 2018

@bflood-agi @nmschulte I was able to reproduce the crash locally and I'll try to look into it in the next week or two

hpinkos pushed a commit that referenced this issue May 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants