Skip to content

Commit 55e2de9

Browse files
authoredApr 28, 2020
Merge pull request #8591 from jony89/patch-1
fix: memory leak event error is not unsubscribing
2 parents 44acf66 + 3ed3565 commit 55e2de9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed
 

‎CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- Fixed an issue with clamping of non-looped glTF animations. Subscribers to animation `update` events should expect one additional event firing as an animation stops. [#7387](https://github.com/CesiumGS/cesium/issues/7387)
2020
- Fixed a bug with very long view ranges requiring multiple frustums even with the logarithmic depth buffer enabled. Previously, such scenes could resolve depth incorrectly. [#8727](https://github.com/CesiumGS/cesium/pull/8727)
2121
- Fixed a bug where the elevation contour material's alpha was not being applied. [#8749](https://github.com/CesiumGS/cesium/pull/8749)
22+
- Fix potential memory leak when destroying `CesiumWidget` instances.
2223

2324
### 1.68.0 - 2020-04-01
2425

‎Source/Widgets/CesiumWidget/CesiumWidget.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,16 @@ function CesiumWidget(container, options) {
366366
this.targetFrameRate = options.targetFrameRate;
367367

368368
var that = this;
369-
scene.renderError.addEventListener(function (scene, error) {
369+
this._onRenderError = function (scene, error) {
370370
that._useDefaultRenderLoop = false;
371371
that._renderLoopRunning = false;
372372
if (that._showRenderLoopErrors) {
373373
var title =
374374
"An error occurred while rendering. Rendering has stopped.";
375375
that.showErrorPanel(title, undefined, error);
376376
}
377-
});
377+
};
378+
scene.renderError.addEventListener(this._onRenderError);
378379
} catch (error) {
379380
if (showRenderLoopErrors) {
380381
var title = "Error constructing CesiumWidget.";
@@ -709,7 +710,10 @@ CesiumWidget.prototype.isDestroyed = function () {
709710
* removing the widget from layout.
710711
*/
711712
CesiumWidget.prototype.destroy = function () {
712-
this._scene = this._scene && this._scene.destroy();
713+
if (defined(this._scene)) {
714+
this._scene.renderError.removeEventListener(this._onRenderError);
715+
this._scene = this._scene.destroy();
716+
}
713717
this._container.removeChild(this._element);
714718
this._creditContainer.removeChild(this._innerCreditContainer);
715719
destroyObject(this);

0 commit comments

Comments
 (0)
Please sign in to comment.