Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const renderCallback = () => {
if (isCancelled !== undefined && isCancelled()) {
mapView.endAnimation();
mapView.removeEventListener(MapViewEventNames.AfterRender, renderCallback);
resolve(undefined);
}
if (waitForFrameLoaded && MapViewUtils.mapViewIsLoading(mapViewApp.mapView)) {
mapViewApp.mapView.update();
} else if (currentFrameNumber >= locations.length) {
mapView.removeEventListener(MapViewEventNames.AfterRender, renderCallback);
const totalTime = PerformanceTimer.now() - startTime;
newStats.appResults.set("flyoverFPS", (1000 * currentFrameNumber) / totalTime);
newStats.appResults.set("flyoverSeconds", totalTime / 1000);
newStats.appResults.set("flyoverFrames", currentFrameNumber);
if (currentFrameNumber > 1) {
const frameEntries = newStats.frameEvents.frameEntries;
// The first frame time is the wrong one, it contains the time stamp from
// the last frame of the previous benchmark run. To get proper statistics,
// we duplicate the value of the seconds frame.
const fullFrameTime = frameEntries.get("render.fullFrameTime")!;
async function recordFramesInner(
mapViewApp: MapViewApp,
numFrames: number,
waitForFinish?: boolean
): Promise {
const frameResults = await renderMapFrame(
mapViewApp,
waitForFinish !== true || numFrames >= 1 ? StatisticsMode.All : StatisticsMode.None
);
const isFinished =
waitForFinish !== true || !MapViewUtils.mapViewIsLoading(mapViewApp.mapView);
if (numFrames > 1 || !isFinished) {
return new Promise((resolve, reject) => {
recordFrames(mapViewApp, numFrames - 1, waitForFinish)
.then(results => {
resolve(results);
})
.catch(() => resolve(undefined));
});
} else {
return new Promise((resolve, reject) => {
resolve(frameResults);
});
}
}
const renderCallback = () => {
if (
mapViewApp.mapView.isDynamicFrame ||
MapViewUtils.mapViewIsLoading(mapViewApp.mapView)
) {
mapViewApp.mapView.update();
} else {
mapView.removeEventListener(MapViewEventNames.AfterRender, renderCallback);
resolve();
}
};