mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Using it, a Flutter app can monitor missing frames in the release mode, and a custom Flutter runner (e.g., Fuchsia) can add a custom FrameRasterizedCallback. Related issues: https://github.com/flutter/flutter/issues/26154 https://github.com/flutter/flutter/issues/31444 https://github.com/flutter/flutter/issues/32447 Need review as soon as possible so we can merge this before the end of May to catch the milestone. Tests added: * NoNeedToReportTimingsByDefault * NeedsReportTimingsIsSetWithCallback * ReportTimingsIsCalled * FrameRasterizedCallbackIsCalled * FrameTimingSetsAndGetsProperly * onReportTimings preserves callback zone * FrameTiming.toString has the correct format This will need a manual engine roll as the TestWindow defined in the framework needs to implement onReportTimings.
60 lines
1.5 KiB
Dart
60 lines
1.5 KiB
Dart
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'dart:isolate';
|
|
import 'dart:ui';
|
|
|
|
void main() {}
|
|
|
|
void nativeReportTimingsCallback(List<int> timings) native 'NativeReportTimingsCallback';
|
|
void nativeOnBeginFrame(int microseconds) native 'NativeOnBeginFrame';
|
|
|
|
@pragma('vm:entry-point')
|
|
void reportTimingsMain() {
|
|
window.onReportTimings = (List<FrameTiming> timings) {
|
|
List<int> timestamps = [];
|
|
for (FrameTiming t in timings) {
|
|
for (FramePhase phase in FramePhase.values) {
|
|
timestamps.add(t.timestampInMicroseconds(phase));
|
|
}
|
|
}
|
|
nativeReportTimingsCallback(timestamps);
|
|
};
|
|
}
|
|
|
|
@pragma('vm:entry-point')
|
|
void onBeginFrameMain() {
|
|
window.onBeginFrame = (Duration beginTime) {
|
|
nativeOnBeginFrame(beginTime.inMicroseconds);
|
|
};
|
|
}
|
|
|
|
@pragma('vm:entry-point')
|
|
void emptyMain() {}
|
|
|
|
@pragma('vm:entry-point')
|
|
void dummyReportTimingsMain() {
|
|
window.onReportTimings = (List<FrameTiming> timings) {};
|
|
}
|
|
|
|
@pragma('vm:entry-point')
|
|
void fixturesAreFunctionalMain() {
|
|
sayHiFromFixturesAreFunctionalMain();
|
|
}
|
|
|
|
void sayHiFromFixturesAreFunctionalMain() native 'SayHiFromFixturesAreFunctionalMain';
|
|
|
|
void notifyNative() native 'NotifyNative';
|
|
|
|
void secondaryIsolateMain(String message) {
|
|
print('Secondary isolate got message: ' + message);
|
|
notifyNative();
|
|
}
|
|
|
|
@pragma('vm:entry-point')
|
|
void testCanLaunchSecondaryIsolate() {
|
|
Isolate.spawn(secondaryIsolateMain, 'Hello from root isolate.');
|
|
notifyNative();
|
|
}
|