flushPaintEvaluation method

void flushPaintEvaluation()

Forces an immediate close of the in-flight VM window so capture tooling can read lastObservedPaintPercent without waiting for the window timer. The partial window's share is its paint time over its own elapsed time. Idempotent — re-running with no new paint time preserves the prior values. Pure observable refresh; does not emit issues (issue emission is owned by _evaluateVmData, reached via _evaluate, which only runs from the scan pipeline).

Updates only lastObservedPaintPercent, never peakObservedPaintPercent. The peak is restricted to naturally closed windows (elapsed ≥ 1 s), the ones whose value is stamped on an emission as observedPaintPercent, so a short partial tail can never become the exported magnitude and the audit gate's 'max' cross-check on emission records stays honest.

Implementation

void flushPaintEvaluation() {
  if (_paintTimeUs <= 0) return;
  final now = _clock();
  final elapsedUs = now.difference(_windowStart).inMicroseconds;
  if (elapsedUs <= 0) return;
  // The partial window refreshes the observable only; it is never
  // staged for evaluation, so no emission can carry a value the peak
  // did not see.
  _lastObservedPaintPercent = (_paintTimeUs / elapsedUs * 100).clamp(
    0.0,
    100.0,
  );
  _pendingEnrichedDirtyTotal = 0;
  _paintTimeUs = 0;
  _windowStart = now;
}