postFrameCallback method

void postFrameCallback()

Implementation

void postFrameCallback() {
  _hasAddPostFrameCall = false;
  if (_startRenderTime > 0) {
    _performanceData.renderTime +=
        currentMicroseconds() - _startRenderTime; // 本次绘制时间
    _performanceData.batchTime += _batchTime;
    _clearData(); //清理数据
    LogUtils.d(kTag, ' postFrameCallback ${_startRenderTime.toString()}');
    _startRenderTime = 0;
    _timer?.cancel();
    _timer = Timer(const Duration(milliseconds: 50), () {
      // 等50毫秒再上报,合并渲染数据,
      if (!_hasAddPostFrameCall) {
        LogUtils.d(kTag, '标签耗时 ${_performanceData.toString()}');
        LogUtils.d(kTag, '组件耗时 ${_performanceData.widgetToString()}');
        _reportCount++;
        performanceCallback(_performanceData, _reportCount);
        _performanceData = PerformanceData(); // 上报后清数据
      }
    });
  }
  _hasAddPostFrameCall = false;
}