Fix calculation of averages in AardTimers

This commit is contained in:
Tamius Han 2025-04-27 17:52:04 +02:00
parent 500d06204c
commit 508ef5cbbb
2 changed files with 7 additions and 5 deletions

View File

@ -349,13 +349,13 @@ export class Aard {
this.startCheck();
}
private createCanvas(canvasId: string, canvasType?: 'webgl' | 'fallback') {
private createCanvas(canvasId: string, canvasType?: 'webgl' | 'legacy') {
if (canvasType) {
if (canvasType === this.settings.active.arDetect.aardType || this.settings.active.arDetect.aardType === 'auto') {
if (canvasType === 'webgl') {
return new GlCanvas({...this.settings.active.arDetect.canvasDimensions.sampleCanvas, id: 'main-gl'});
} else if (canvasType === 'fallback') {
return new FallbackCanvas({...this.settings.active.arDetect.canvasDimensions.sampleCanvas, id: 'main-fallback'});
} else if (canvasType === 'legacy') {
return new FallbackCanvas({...this.settings.active.arDetect.canvasDimensions.sampleCanvas, id: 'main-legacy'});
} else {
// TODO: throw error
}
@ -556,7 +556,7 @@ export class Aard {
} else {
if (this.settings.active.arDetect.aardType === 'auto') {
this.canvasStore.main.destroy();
this.canvasStore.main = this.createCanvas('main-gl', 'fallback');
this.canvasStore.main = this.createCanvas('main-gl', 'legacy');
}
this.inFallback = true;
this.fallbackReason = {cors: true};

View File

@ -23,7 +23,9 @@ export class AardTimer {
constructor() {
this.aardPerformanceDataBuffer = new Array<AardPerformanceData>(16).fill(this.getEmptyMeasurement());
// we need to deep clone, otherwise all buffer objects will point to the same object
// (this makes calculating averages impossible)
this.aardPerformanceDataBuffer = JSON.parse(JSON.stringify(new Array<AardPerformanceData>(64).fill(this.getEmptyMeasurement())));
this.current = this.aardPerformanceDataBuffer[0];
this.previous = undefined;
this.lastChange = this.getEmptyMeasurement();