Add FPS logging to OutfitMovieLayer
This is a precursor to adding an emergency brake if the FPS gets too low lol
This commit is contained in:
parent
25376a8fa8
commit
307ab932c8
1 changed files with 25 additions and 5 deletions
|
@ -165,12 +165,32 @@ function OutfitMovieLayer({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const intervalId = setInterval(
|
let lastFpsLoggedAtInMs = performance.now();
|
||||||
() => updateStage(),
|
let numFramesSinceLastLogged = 0;
|
||||||
1000 / library.properties.fps
|
const intervalId = setInterval(() => {
|
||||||
);
|
updateStage();
|
||||||
|
|
||||||
|
numFramesSinceLastLogged++;
|
||||||
|
|
||||||
|
const now = performance.now();
|
||||||
|
const timeSinceLastFpsLoggedAtInMs = now - lastFpsLoggedAtInMs;
|
||||||
|
const timeSinceLastFpsLoggedAtInSec = timeSinceLastFpsLoggedAtInMs / 1000;
|
||||||
|
|
||||||
|
if (timeSinceLastFpsLoggedAtInSec > 2) {
|
||||||
|
const fps = numFramesSinceLastLogged / timeSinceLastFpsLoggedAtInSec;
|
||||||
|
const roundedFps = Math.round(fps * 100) / 100;
|
||||||
|
|
||||||
|
console.debug(
|
||||||
|
`[OutfitMovieLayer] FPS: ${roundedFps} (Target: ${library.properties.fps}, ${numFramesSinceLastLogged}, ${timeSinceLastFpsLoggedAtInSec}) (${libraryUrl})`
|
||||||
|
);
|
||||||
|
|
||||||
|
lastFpsLoggedAtInMs = now;
|
||||||
|
numFramesSinceLastLogged = 0;
|
||||||
|
}
|
||||||
|
}, 1000 / library.properties.fps);
|
||||||
|
|
||||||
return () => clearInterval(intervalId);
|
return () => clearInterval(intervalId);
|
||||||
}, [stage, updateStage, movieClip, library, isPaused]);
|
}, [libraryUrl, stage, updateStage, movieClip, library, isPaused]);
|
||||||
|
|
||||||
// This effect keeps the `movieClip` scaled correctly, based on the canvas
|
// This effect keeps the `movieClip` scaled correctly, based on the canvas
|
||||||
// size and the `library`'s natural size declaration. (If the canvas size
|
// size and the `library`'s natural size declaration. (If the canvas size
|
||||||
|
|
Loading…
Reference in a new issue