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: memory leak event error is not unsubscribing #8591

Merged
merged 4 commits into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- 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)
- 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)
- Fixed a bug where the elevation contour material's alpha was not being applied. [#8749](https://github.com/CesiumGS/cesium/pull/8749)
- Fix potential memory leak when destroying `CesiumWidget` instances.

### 1.68.0 - 2020-04-01

Expand Down
10 changes: 7 additions & 3 deletions Source/Widgets/CesiumWidget/CesiumWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,15 +366,16 @@ function CesiumWidget(container, options) {
this.targetFrameRate = options.targetFrameRate;

var that = this;
scene.renderError.addEventListener(function (scene, error) {
this._onRenderError = function (scene, error) {
that._useDefaultRenderLoop = false;
that._renderLoopRunning = false;
if (that._showRenderLoopErrors) {
var title =
"An error occurred while rendering. Rendering has stopped.";
that.showErrorPanel(title, undefined, error);
}
});
};
scene.renderError.addEventListener(this._onRenderError);
} catch (error) {
if (showRenderLoopErrors) {
var title = "Error constructing CesiumWidget.";
Expand Down Expand Up @@ -709,7 +710,10 @@ CesiumWidget.prototype.isDestroyed = function () {
* removing the widget from layout.
*/
CesiumWidget.prototype.destroy = function () {
this._scene = this._scene && this._scene.destroy();
if (defined(this._scene)) {
this._scene.renderError.removeEventListener(this._onRenderError);
this._scene = this._scene.destroy();
}
this._container.removeChild(this._element);
this._creditContainer.removeChild(this._innerCreditContainer);
destroyObject(this);
Expand Down