processTimelineData method

  1. @override
void processTimelineData(
  1. ParsedTimelineData data
)
override

Process VM timeline data.

No-op for DetectorLifecycle.structural detectors. Override in vmOnly and hybrid detectors.

Implementation

@override
void processTimelineData(ParsedTimelineData data) {
  if (!_isEnabled) return;
  // Cold-start polls carry pipeline-compilation raster frames against
  // almost no UI work; the frame leg ignores them and so does this leg.
  if (_insideStartupWindow()) return;
  if (data.rasterDurations.isEmpty) return;
  final totalUi =
      data.totalBuildScopeUs +
      data.totalFlushLayoutUs +
      data.totalFlushPaintUs;
  // A batch without UI work has no ratio to judge.
  if (totalUi <= 0) return;
  // A poll carries about half a second of frames, and the timeline does
  // not pair a frame's raster with its UI work. Each raster frame is set
  // against the UI time of an average frame in the batch, not the batch's
  // total, which grows with the frame count.
  final perFrame = totalUi ~/ data.rasterDurations.length;
  final uiPerFrameUs = perFrame > 0 ? perFrame : 1;
  final budgetUs = effectiveMaxFrameRasterFloorUs;
  var missed = 0;
  for (final rasterUs in data.rasterDurations) {
    if (rasterUs <= budgetUs) continue;
    if (rasterUs <= rasterMultiplierThreshold * uiPerFrameUs) continue;
    missed++;
    if (rasterUs > _vmWorstRasterUs) {
      _vmWorstRasterUs = rasterUs;
      _vmWorstBatchUiUs = uiPerFrameUs;
    }
  }
  if (missed > _vmMissedInBatch) _vmMissedInBatch = missed;
}