explicitly destroy block scenes

This commit is contained in:
Mononaut 2025-01-06 19:02:24 +00:00
parent 6553344489
commit 9f5666f410
No known key found for this signature in database
GPG Key ID: A3F058E41374C04E
6 changed files with 28 additions and 4 deletions

View File

@ -172,12 +172,17 @@ export class BlockOverviewGraphComponent implements AfterViewInit, OnDestroy, On
ngOnDestroy(): void { ngOnDestroy(): void {
if (this.animationFrameRequest) { if (this.animationFrameRequest) {
cancelAnimationFrame(this.animationFrameRequest); cancelAnimationFrame(this.animationFrameRequest);
clearTimeout(this.animationHeartBeat);
} }
clearTimeout(this.animationHeartBeat);
if (this.canvas) { if (this.canvas) {
this.canvas.nativeElement.removeEventListener('webglcontextlost', this.handleContextLost); this.canvas.nativeElement.removeEventListener('webglcontextlost', this.handleContextLost);
this.canvas.nativeElement.removeEventListener('webglcontextrestored', this.handleContextRestored); this.canvas.nativeElement.removeEventListener('webglcontextrestored', this.handleContextRestored);
} }
if (this.scene) {
this.scene.destroy();
}
this.vertexArray.destroy();
this.vertexArray = null;
this.themeChangedSubscription?.unsubscribe(); this.themeChangedSubscription?.unsubscribe();
this.searchSubscription?.unsubscribe(); this.searchSubscription?.unsubscribe();
} }
@ -490,9 +495,7 @@ export class BlockOverviewGraphComponent implements AfterViewInit, OnDestroy, On
if (this.running && this.scene && now <= (this.scene.animateUntil + 500)) { if (this.running && this.scene && now <= (this.scene.animateUntil + 500)) {
this.doRun(); this.doRun();
} else { } else {
if (this.animationHeartBeat) { clearTimeout(this.animationHeartBeat);
clearTimeout(this.animationHeartBeat);
}
this.animationHeartBeat = window.setTimeout(() => { this.animationHeartBeat = window.setTimeout(() => {
this.start(); this.start();
}, 1000); }, 1000);

View File

@ -110,4 +110,12 @@ export class FastVertexArray {
getVertexData(): Float32Array { getVertexData(): Float32Array {
return this.data; return this.data;
} }
destroy(): void {
this.data = null;
this.sprites = null;
this.freeSlots = null;
this.lastSlot = 0;
this.dirty = false;
}
} }

View File

@ -176,5 +176,8 @@ export class BlockViewComponent implements OnInit, OnDestroy {
if (this.queryParamsSubscription) { if (this.queryParamsSubscription) {
this.queryParamsSubscription.unsubscribe(); this.queryParamsSubscription.unsubscribe();
} }
if (this.blockGraph) {
this.blockGraph.destroy();
}
} }
} }

View File

@ -428,6 +428,12 @@ export class BlockComponent implements OnInit, OnDestroy {
this.isAuditEnabledSubscription?.unsubscribe(); this.isAuditEnabledSubscription?.unsubscribe();
this.oobSubscription?.unsubscribe(); this.oobSubscription?.unsubscribe();
this.priceSubscription?.unsubscribe(); this.priceSubscription?.unsubscribe();
this.blockGraphProjected.forEach(graph => {
graph.destroy();
});
this.blockGraphActual.forEach(graph => {
graph.destroy();
});
} }
// TODO - Refactor this.fees/this.reward for liquid because it is not // TODO - Refactor this.fees/this.reward for liquid because it is not

View File

@ -162,6 +162,9 @@ export class EightBlocksComponent implements OnInit, OnDestroy {
this.cacheBlocksSubscription?.unsubscribe(); this.cacheBlocksSubscription?.unsubscribe();
this.networkChangedSubscription?.unsubscribe(); this.networkChangedSubscription?.unsubscribe();
this.queryParamsSubscription?.unsubscribe(); this.queryParamsSubscription?.unsubscribe();
this.blockGraphs.forEach(graph => {
graph.destroy();
});
} }
shiftTestBlocks(): void { shiftTestBlocks(): void {

View File

@ -120,6 +120,7 @@ export class MempoolBlockOverviewComponent implements OnInit, OnDestroy, OnChang
} }
ngOnDestroy(): void { ngOnDestroy(): void {
this.blockGraph?.destroy();
this.blockSub.unsubscribe(); this.blockSub.unsubscribe();
this.timeLtrSubscription.unsubscribe(); this.timeLtrSubscription.unsubscribe();
this.websocketService.stopTrackMempoolBlock(); this.websocketService.stopTrackMempoolBlock();