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

Fix crashes due to shared PolylineCollection among all CustomDataSources #7758 #9154 #11640

Merged
merged 12 commits into from
Jan 16, 2024
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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