Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions packages/core/src/application/application_ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ import {TESTABILITY} from '../testability/testability';
import {isPromise} from '../util/lang';
import {NgZone} from '../zone/ng_zone';

import {profiler} from '../render3/profiler';
import {ProfilerEvent} from '../render3/profiler_types';
import {EffectScheduler} from '../render3/reactivity/root_effect_scheduler';
import {ApplicationInitStatus} from './application_init';
import {TracingAction, TracingService, TracingSnapshot} from './tracing';
import {EffectScheduler} from '../render3/reactivity/root_effect_scheduler';
import {ProfilerEvent} from '../render3/profiler_types';
import {profiler} from '../render3/profiler';

/**
* A DI token that provides a set of callbacks to
Expand Down Expand Up @@ -604,21 +604,20 @@ export class ApplicationRef {
}

/** @internal */
_tick = (): void => {
_tick(): void {
profiler(ProfilerEvent.ChangeDetectionStart);

Comment thread
mmalerba marked this conversation as resolved.
Outdated
if (this.tracingSnapshot !== null) {
const snapshot = this.tracingSnapshot;
this.tracingSnapshot = null;

// Ensure we always run `_tick()` in the context of the most recent snapshot,
// Ensure we always run `tickImpl()` in the context of the most recent snapshot,
// if one exists. Snapshots may be reference counted by the implementation so
// we want to ensure that if we request a snapshot that we use it.
snapshot.run(TracingAction.CHANGE_DETECTION, this._tick);
snapshot.dispose();
return;
this.tracingSnapshot.run(TracingAction.CHANGE_DETECTION, this.tickImpl);
} else {
this.tickImpl();
}
}

private tickImpl = (): void => {
(typeof ngDevMode === 'undefined' || ngDevMode) && warnIfDestroyed(this._destroyed);
if (this._runningTick) {
throw new RuntimeError(
Expand All @@ -641,6 +640,8 @@ export class ApplicationRef {
this.internalErrorHandler(e);
} finally {
this._runningTick = false;
this.tracingSnapshot?.dispose();
this.tracingSnapshot = null;
setActiveConsumer(prevConsumer);
this.afterTick.next();

Expand Down