Guarding performance.mark
MODIFY
addon/scheduler.ts
addon/scheduler.ts
@@ -38,7 +38,7 @@ export function beginTransition(): void {
});
}).finally(() => {
waiter.endAsync(scheduledWorkToken);
- performance.mark('appSchedulerEnd');
+ mark('appSchedulerEnd');
measure('appScheduler', 'appSchedulerStart', 'appSchedulerEnd');
});
});
@@ -47,7 +47,7 @@ export function beginTransition(): void {
export function endTransition(): void {
_whenRouteDidChange.resolve();
- performance.mark('appSchedulerStart');
+ mark('appSchedulerStart');
}
export function setupRouter(router: Router): void {
@@ -159,6 +159,16 @@ function _defer(label: string): Deferred {
};
}
+function mark(markName: string): void {
+ try {
+ performance.mark(markName);
+ } catch (ex) {
+ console.warn(
+ `performance.mark could not be executed because of ${ex.message}`
+ );
+ }
+}
+
function measure(
measureName: string,
startMark: string | undefined,
@@ -168,8 +178,7 @@ function measure(
performance.measure(measureName, startMark, endMark);
} catch (ex) {
console.warn(
- 'performance.measure could not be executed because of ',
- ex.message
+ `performance.measure could not be executed because of ${ex.message}`
);
}
}

Guarding performance.mark (#511)