Skip to content

Commit

Permalink
Merge pull request #11640 from rropp5/main
Browse files Browse the repository at this point in the history
Fix crashes due to shared PolylineCollection among all CustomDataSources #7758 #9154
  • Loading branch information
ggetz committed Jan 16, 2024
2 parents c7edfae + 8b2f4bb commit 59244ce
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -22,6 +22,7 @@
- Fix globe materials when lighting is false. Slope/Aspect material no longer rely on turning on lighting or shadows. [#11563](https://github.com/CesiumGS/cesium/issues/11563)
- Fixed a bug where `GregorianDate` constructor would not validate the input parameters for valid date. [#10075](https://github.com/CesiumGS/cesium/pull/10075)
- Fixed improper scaling of ellipsoid inner radii in 3D mode. [#11656](https://github.com/CesiumGS/cesium/issues/11656) and [#10245](https://github.com/CesiumGS/cesium/issues/10245)
- Fixed an issue where `DataSource` objects incorrectly shared a single `PolylineCollection` in the `PolylineGeometryUpdater`. Updated `PolylineGeometryUpdater` to create a distinct `PolylineCollection` instance per `DataSource`. This resolves the crashes reported under [#7758](https://github.com/CesiumGS/cesium/issues/7758) and [#9154](https://github.com/CesiumGS/cesium/issues/9154).

#### @cesium/widgets

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Expand Up @@ -371,6 +371,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
- [hongfaqiu](https://github.com/hongfaqiu)
- [KOBAYASHI Ittoku](https://github.com/kittoku)
- [王康](https://github.com/yieryi)
- [rropp5](https://github.com/rropp5)
- [孙永政](https://github.com/syzdev)
- [Subhajit Saha](https://github.com/subhajits)
- [Jared Webber](https://github.com/jaredwebber)
Expand Down
14 changes: 8 additions & 6 deletions packages/engine/Source/DataSources/PolylineGeometryUpdater.js
Expand Up @@ -661,12 +661,13 @@ function getLine(dynamicGeometryUpdater) {
return dynamicGeometryUpdater._line;
}

const sceneId = dynamicGeometryUpdater._geometryUpdater._scene.id;
let polylineCollection = polylineCollections[sceneId];
const primitives = dynamicGeometryUpdater._primitives;
const polylineCollectionId =
dynamicGeometryUpdater._geometryUpdater._scene.id + primitives._guid;
let polylineCollection = polylineCollections[polylineCollectionId];
if (!defined(polylineCollection) || polylineCollection.isDestroyed()) {
polylineCollection = new PolylineCollection();
polylineCollections[sceneId] = polylineCollection;
polylineCollections[polylineCollectionId] = polylineCollection;
primitives.add(polylineCollection);
} else if (!primitives.contains(polylineCollection)) {
primitives.add(polylineCollection);
Expand Down Expand Up @@ -869,13 +870,14 @@ DynamicGeometryUpdater.prototype.isDestroyed = function () {

DynamicGeometryUpdater.prototype.destroy = function () {
const geometryUpdater = this._geometryUpdater;
const sceneId = geometryUpdater._scene.id;
const polylineCollection = polylineCollections[sceneId];
const polylineCollectionId =
geometryUpdater._scene.id + this._primitives._guid;
const polylineCollection = polylineCollections[polylineCollectionId];
if (defined(polylineCollection)) {
polylineCollection.remove(this._line);
if (polylineCollection.length === 0) {
this._primitives.removeAndDestroy(polylineCollection);
delete polylineCollections[sceneId];
delete polylineCollections[polylineCollectionId];
}
}
if (defined(this._groundPolylinePrimitive)) {
Expand Down

0 comments on commit 59244ce

Please sign in to comment.