Fix error when disposing ol/renderer/webgl/TileLayer
- helper may not exist - tileTextureCache not cleared when canvasCacheKey changes
This commit is contained in:
@@ -95,7 +95,7 @@ class WebGLLayerRenderer extends LayerRenderer {
|
|||||||
*/
|
*/
|
||||||
this.helper;
|
this.helper;
|
||||||
|
|
||||||
layer.addChangeListener(LayerProperty.MAP, this.removeHelper_.bind(this));
|
layer.addChangeListener(LayerProperty.MAP, this.removeHelper.bind(this));
|
||||||
|
|
||||||
this.dispatchPreComposeEvent = this.dispatchPreComposeEvent.bind(this);
|
this.dispatchPreComposeEvent = this.dispatchPreComposeEvent.bind(this);
|
||||||
this.dispatchPostComposeEvent = this.dispatchPostComposeEvent.bind(this);
|
this.dispatchPostComposeEvent = this.dispatchPostComposeEvent.bind(this);
|
||||||
@@ -148,7 +148,10 @@ class WebGLLayerRenderer extends LayerRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
removeHelper_() {
|
/**
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
removeHelper() {
|
||||||
if (this.helper) {
|
if (this.helper) {
|
||||||
this.helper.dispose();
|
this.helper.dispose();
|
||||||
delete this.helper;
|
delete this.helper;
|
||||||
@@ -187,9 +190,7 @@ class WebGLLayerRenderer extends LayerRenderer {
|
|||||||
'map/' + frameState.mapId + '/group/' + groupNumber;
|
'map/' + frameState.mapId + '/group/' + groupNumber;
|
||||||
|
|
||||||
if (!this.helper || !this.helper.canvasCacheKeyMatches(canvasCacheKey)) {
|
if (!this.helper || !this.helper.canvasCacheKeyMatches(canvasCacheKey)) {
|
||||||
if (this.helper) {
|
this.removeHelper();
|
||||||
this.helper.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.helper = new WebGLHelper({
|
this.helper = new WebGLHelper({
|
||||||
postProcesses: this.postProcesses_,
|
postProcesses: this.postProcesses_,
|
||||||
@@ -227,7 +228,7 @@ class WebGLLayerRenderer extends LayerRenderer {
|
|||||||
* Clean up.
|
* Clean up.
|
||||||
*/
|
*/
|
||||||
disposeInternal() {
|
disposeInternal() {
|
||||||
this.removeHelper_();
|
this.removeHelper();
|
||||||
super.disposeInternal();
|
super.disposeInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -683,27 +683,33 @@ class WebGLTileLayerRenderer extends WebGLLayerRenderer {
|
|||||||
return covered;
|
return covered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeHelper() {
|
||||||
|
if (this.helper) {
|
||||||
|
const tileTextureCache = this.tileTextureCache_;
|
||||||
|
tileTextureCache.forEach((tileTexture) => tileTexture.dispose());
|
||||||
|
tileTextureCache.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.removeHelper();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clean up.
|
* Clean up.
|
||||||
*/
|
*/
|
||||||
disposeInternal() {
|
disposeInternal() {
|
||||||
const helper = this.helper;
|
const helper = this.helper;
|
||||||
const gl = helper.getGL();
|
if (helper) {
|
||||||
|
const gl = helper.getGL();
|
||||||
|
gl.deleteProgram(this.program_);
|
||||||
|
delete this.program_;
|
||||||
|
|
||||||
helper.deleteBuffer(this.indices_);
|
helper.deleteBuffer(this.indices_);
|
||||||
delete this.indices_;
|
}
|
||||||
|
|
||||||
gl.deleteProgram(this.program_);
|
|
||||||
delete this.program_;
|
|
||||||
|
|
||||||
const tileTextureCache = this.tileTextureCache_;
|
|
||||||
tileTextureCache.forEach(function (tileTexture) {
|
|
||||||
tileTexture.dispose();
|
|
||||||
});
|
|
||||||
tileTextureCache.clear();
|
|
||||||
delete this.tileTextureCache_;
|
|
||||||
|
|
||||||
super.disposeInternal();
|
super.disposeInternal();
|
||||||
|
|
||||||
|
delete this.indices_;
|
||||||
|
delete this.tileTextureCache_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user