Unverified Commit 25c84001 authored by Devon Carew's avatar Devon Carew Committed by GitHub

Revert "update the Flutter.Frame event to use new engine APIs (#34243)" (#34352)

This reverts commit 446179f6.
parent c40d701e
......@@ -4,8 +4,8 @@
import 'dart:async';
import 'dart:collection';
import 'dart:developer' show Flow, Timeline;
import 'dart:ui' show AppLifecycleState, FramePhase, FrameTiming;
import 'dart:developer';
import 'dart:ui' show AppLifecycleState;
import 'package:collection/collection.dart' show PriorityQueue, HeapPriorityQueue;
import 'package:flutter/foundation.dart';
......@@ -198,17 +198,6 @@ mixin SchedulerBinding on BindingBase, ServicesBinding {
window.onDrawFrame = _handleDrawFrame;
SystemChannels.lifecycle.setMessageHandler(_handleLifecycleMessage);
readInitialLifecycleStateFromNativeWindow();
if (!kReleaseMode) {
int frameNumber = 0;
window.onReportTimings = (List<FrameTiming> timings) {
for (FrameTiming frameTiming in timings) {
frameNumber += 1;
_profileFramePostEvent(frameNumber, frameTiming);
}
};
}
}
/// The current [SchedulerBinding], if one has been created.
......@@ -853,7 +842,8 @@ mixin SchedulerBinding on BindingBase, ServicesBinding {
}
Duration _currentFrameTimeStamp;
int _debugFrameNumber = 0;
int _profileFrameNumber = 0;
final Stopwatch _profileFrameStopwatch = Stopwatch();
String _debugBanner;
bool _ignoreNextEngineDrawFrame = false;
......@@ -904,9 +894,13 @@ mixin SchedulerBinding on BindingBase, ServicesBinding {
if (rawTimeStamp != null)
_lastRawTimeStamp = rawTimeStamp;
assert(() {
_debugFrameNumber += 1;
if (!kReleaseMode) {
_profileFrameNumber += 1;
_profileFrameStopwatch.reset();
_profileFrameStopwatch.start();
}
assert(() {
if (debugPrintBeginFrameBanner || debugPrintEndFrameBanner) {
final StringBuffer frameTimeStampDescription = StringBuffer();
if (rawTimeStamp != null) {
......@@ -914,7 +908,7 @@ mixin SchedulerBinding on BindingBase, ServicesBinding {
} else {
frameTimeStampDescription.write('(warm-up frame)');
}
_debugBanner = '▄▄▄▄▄▄▄▄ Frame ${_debugFrameNumber.toString().padRight(7)} ${frameTimeStampDescription.toString().padLeft(18)} ▄▄▄▄▄▄▄▄';
_debugBanner = '▄▄▄▄▄▄▄▄ Frame ${_profileFrameNumber.toString().padRight(7)} ${frameTimeStampDescription.toString().padLeft(18)} ▄▄▄▄▄▄▄▄';
if (debugPrintBeginFrameBanner)
debugPrint(_debugBanner);
}
......@@ -967,6 +961,10 @@ mixin SchedulerBinding on BindingBase, ServicesBinding {
} finally {
_schedulerPhase = SchedulerPhase.idle;
Timeline.finishSync(); // end the Frame
if (!kReleaseMode) {
_profileFrameStopwatch.stop();
_profileFramePostEvent();
}
assert(() {
if (debugPrintEndFrameBanner)
debugPrint('▀' * _debugBanner.length);
......@@ -977,13 +975,11 @@ mixin SchedulerBinding on BindingBase, ServicesBinding {
}
}
void _profileFramePostEvent(int frameNumber, FrameTiming frameTiming) {
void _profileFramePostEvent() {
postEvent('Flutter.Frame', <String, dynamic>{
'number': frameNumber,
'startTime': frameTiming.timestampInMicroseconds(FramePhase.buildStart),
'elapsed': frameTiming.totalSpan.inMicroseconds,
'build': frameTiming.buildDuration.inMicroseconds,
'raster': frameTiming.rasterDuration.inMicroseconds,
'number': _profileFrameNumber,
'startTime': _currentFrameTimeStamp.inMicroseconds,
'elapsed': _profileFrameStopwatch.elapsedMicroseconds,
});
}
......
......@@ -3,7 +3,6 @@
// found in the LICENSE file.
import 'dart:async';
import 'dart:ui' show window, FrameTiming;
import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart';
......@@ -11,18 +10,7 @@ import 'package:flutter/services.dart';
import '../flutter_test_alternative.dart';
class TestSchedulerBinding extends BindingBase with ServicesBinding, SchedulerBinding {
final Map<String, List<Map<String, dynamic>>> eventsDispatched = <String, List<Map<String, dynamic>>>{};
@override
void postEvent(String eventKind, Map<dynamic, dynamic> eventData) {
getEventsDispatched(eventKind).add(eventData);
}
List<Map<String, dynamic>> getEventsDispatched(String eventKind) {
return eventsDispatched.putIfAbsent(eventKind, () => <Map<String, dynamic>>[]);
}
}
class TestSchedulerBinding extends BindingBase with ServicesBinding, SchedulerBinding { }
class TestStrategy {
int allowedPriority = 10000;
......@@ -33,8 +21,7 @@ class TestStrategy {
}
void main() {
TestSchedulerBinding scheduler;
SchedulerBinding scheduler;
setUpAll(() {
scheduler = TestSchedulerBinding();
});
......@@ -129,23 +116,4 @@ void main() {
expect(timerQueueTasks.length, 2);
expect(taskExecuted, false);
});
test('Flutter.Frame event fired', () async {
window.onReportTimings(<FrameTiming>[FrameTiming(<int>[
// build start, build finish
10000, 15000,
// raster start, raster finish
16000, 20000,
])]);
final List<Map<String, dynamic>> events = scheduler.getEventsDispatched('Flutter.Frame');
expect(events, hasLength(1));
final Map<String, dynamic> event = events.first;
expect(event['number'], isNonNegative);
expect(event['startTime'], 10000);
expect(event['elapsed'], 10000);
expect(event['build'], 5000);
expect(event['raster'], 4000);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment