updateDebugSnapshot method

  1. @override
void updateDebugSnapshot(
  1. DebugSnapshot snapshot
)
override

Called with debug callback data when available.

Only invoked in debug mode when enableDebugCallbacks is true. Detectors MUST use DebugSnapshot.elapsed to normalize counts to per-second rates before applying thresholds.

Implementation

@override
void updateDebugSnapshot(DebugSnapshot snapshot) {
  _pendingDebugSnapshot = snapshot;
  final us = snapshot.elapsed.inMicroseconds;
  // Gate A: a type's rate is its busiest instance's origin count, which
  // already leaves out frames an animation owner drove. Instances are
  // never summed, so forty widgets of one type at 10/sec each read as
  // 10/sec.
  _perWidget.update(
    counts: {
      for (final MapEntry(key: type, value: origins)
          in snapshot.paintOrigins.entries)
        if (origins.maxCount > 0) type: origins.maxCount,
    },
    elapsedUs: us,
    capped: snapshot.paintOriginTypesCapped,
    thresholdFor: (_) => paintFrequencyThreshold.toDouble(),
    criticalMultiplier: debugCriticalMultiplier.toDouble(),
  );
  // Gate B — the VM share is not shown while *every* paint in the
  // window, framework paints included, was animation-owned. The
  // per-widget maps hold only user widgets, so they cannot tell.
  _debugAllOwned =
      _perWidget.held.isEmpty &&
      snapshot.totalPaintCount > 0 &&
      snapshot.totalAnimationOwnedPaintCount >= snapshot.totalPaintCount;
}