@@ -43,11 +43,11 @@ import {ViewRef as InternalViewRef} from '../render3/view_ref';
4343import { TESTABILITY } from '../testability/testability' ;
4444import { NgZone } from '../zone/ng_zone' ;
4545
46+ import { profiler } from '../render3/profiler' ;
47+ import { ProfilerEvent } from '../render3/profiler_types' ;
48+ import { EffectScheduler } from '../render3/reactivity/root_effect_scheduler' ;
4649import { ApplicationInitStatus } from './application_init' ;
4750import { TracingAction , TracingService , TracingSnapshot } from './tracing' ;
48- import { EffectScheduler } from '../render3/reactivity/root_effect_scheduler' ;
49- import { ProfilerEvent } from '../render3/profiler_types' ;
50- import { profiler } from '../render3/profiler' ;
5151
5252/**
5353 * A DI token that provides a set of callbacks to
@@ -580,21 +580,20 @@ export class ApplicationRef {
580580 }
581581
582582 /** @internal */
583- _tick = ( ) : void => {
583+ _tick ( ) : void {
584584 profiler ( ProfilerEvent . ChangeDetectionStart ) ;
585585
586586 if ( this . tracingSnapshot !== null ) {
587- const snapshot = this . tracingSnapshot ;
588- this . tracingSnapshot = null ;
589-
590- // Ensure we always run `_tick()` in the context of the most recent snapshot,
587+ // Ensure we always run `tickImpl()` in the context of the most recent snapshot,
591588 // if one exists. Snapshots may be reference counted by the implementation so
592589 // we want to ensure that if we request a snapshot that we use it.
593- snapshot . run ( TracingAction . CHANGE_DETECTION , this . _tick ) ;
594- snapshot . dispose ( ) ;
595- return ;
590+ this . tracingSnapshot . run ( TracingAction . CHANGE_DETECTION , this . tickImpl ) ;
591+ } else {
592+ this . tickImpl ( ) ;
596593 }
594+ }
597595
596+ private tickImpl = ( ) : void => {
598597 ( typeof ngDevMode === 'undefined' || ngDevMode ) && warnIfDestroyed ( this . _destroyed ) ;
599598 if ( this . _runningTick ) {
600599 throw new RuntimeError (
@@ -617,6 +616,8 @@ export class ApplicationRef {
617616 this . internalErrorHandler ( e ) ;
618617 } finally {
619618 this . _runningTick = false ;
619+ this . tracingSnapshot ?. dispose ( ) ;
620+ this . tracingSnapshot = null ;
620621 setActiveConsumer ( prevConsumer ) ;
621622 this . afterTick . next ( ) ;
622623
0 commit comments