This reverts commit e2490f2906.
This commit is contained in:
@@ -32,7 +32,7 @@ Future<void> main() async {
|
||||
child: ComplexLayoutApp(),
|
||||
),
|
||||
));
|
||||
await SchedulerBinding.instance.endOfFrame;
|
||||
await SchedulerBinding.instance?.endOfFrame;
|
||||
|
||||
/// Wait 50ms to allow the raster thread to actually put up the frame. (The
|
||||
/// endOfFrame future ends when we send the data to the engine, before
|
||||
@@ -50,9 +50,9 @@ Future<void> main() async {
|
||||
child: ComplexLayoutApp(),
|
||||
),
|
||||
));
|
||||
await SchedulerBinding.instance.endOfFrame;
|
||||
await SchedulerBinding.instance?.endOfFrame;
|
||||
|
||||
final WidgetController controller = LiveWidgetController(WidgetsBinding.instance);
|
||||
final WidgetController controller = LiveWidgetController(WidgetsBinding.instance!);
|
||||
|
||||
// Scroll down
|
||||
for (int iteration = 0; iteration < maxIterations; iteration += 1) {
|
||||
|
||||
@@ -41,7 +41,7 @@ class _FilteredChildAnimationPageState extends State<FilteredChildAnimationPage>
|
||||
_filterType = widget.initialFilterType;
|
||||
_complexChild = widget.initialComplexChild;
|
||||
_useRepaintBoundary = widget.initialUseRepaintBoundary;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
final RenderBox childBox = _childKey.currentContext!.findRenderObject()! as RenderBox;
|
||||
_childCenter = childBox.paintBounds.center;
|
||||
});
|
||||
|
||||
@@ -11,7 +11,7 @@ class LargeImagesPage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ImageCache imageCache = PaintingBinding.instance.imageCache;
|
||||
final ImageCache imageCache = PaintingBinding.instance!.imageCache!;
|
||||
imageCache.maximumSize = 30;
|
||||
imageCache.maximumSizeBytes = 50 << 20;
|
||||
return GridView.builder(
|
||||
|
||||
@@ -66,7 +66,7 @@ class BenchMouseRegionGridHover extends WidgetRecorder {
|
||||
void frameDidDraw() {
|
||||
if (!started) {
|
||||
started = true;
|
||||
SchedulerBinding.instance.addPostFrameCallback((Duration timeStamp) async {
|
||||
SchedulerBinding.instance!.addPostFrameCallback((Duration timeStamp) async {
|
||||
_tester.start();
|
||||
registerDidStop(_tester.stop);
|
||||
});
|
||||
@@ -124,7 +124,7 @@ class _UntilNextFrame {
|
||||
static Future<void> wait() {
|
||||
if (_UntilNextFrame._completer == null) {
|
||||
_UntilNextFrame._completer = Completer<void>();
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
SchedulerBinding.instance!.addPostFrameCallback((_) {
|
||||
_UntilNextFrame._completer!.complete(null);
|
||||
_UntilNextFrame._completer = null;
|
||||
});
|
||||
@@ -145,7 +145,7 @@ class _Tester {
|
||||
TestGesture get gesture {
|
||||
return _gesture ??= TestGesture(
|
||||
dispatcher: (PointerEvent event) async {
|
||||
RendererBinding.instance.handlePointerEvent(event);
|
||||
RendererBinding.instance!.handlePointerEvent(event);
|
||||
},
|
||||
kind: PointerDeviceKind.mouse,
|
||||
);
|
||||
|
||||
@@ -41,7 +41,7 @@ class BenchMouseRegionGridScroll extends WidgetRecorder {
|
||||
void frameDidDraw() {
|
||||
if (!started) {
|
||||
started = true;
|
||||
SchedulerBinding.instance.addPostFrameCallback((Duration timeStamp) async {
|
||||
SchedulerBinding.instance!.addPostFrameCallback((Duration timeStamp) async {
|
||||
_tester.start();
|
||||
registerDidStop(_tester.stop);
|
||||
});
|
||||
@@ -96,7 +96,7 @@ class _UntilNextFrame {
|
||||
static Future<void> wait() {
|
||||
if (_UntilNextFrame._completer == null) {
|
||||
_UntilNextFrame._completer = Completer<void>();
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
SchedulerBinding.instance!.addPostFrameCallback((_) {
|
||||
_UntilNextFrame._completer!.complete(null);
|
||||
_UntilNextFrame._completer = null;
|
||||
});
|
||||
@@ -117,7 +117,7 @@ class _Tester {
|
||||
TestGesture get gesture {
|
||||
return _gesture ??= TestGesture(
|
||||
dispatcher: (PointerEvent event) async {
|
||||
RendererBinding.instance.handlePointerEvent(event);
|
||||
RendererBinding.instance!.handlePointerEvent(event);
|
||||
},
|
||||
kind: PointerDeviceKind.mouse,
|
||||
);
|
||||
|
||||
@@ -85,7 +85,7 @@ class BenchMouseRegionMixedGridHover extends WidgetRecorder {
|
||||
void frameDidDraw() {
|
||||
if (!started) {
|
||||
started = true;
|
||||
SchedulerBinding.instance.addPostFrameCallback((Duration timeStamp) async {
|
||||
SchedulerBinding.instance!.addPostFrameCallback((Duration timeStamp) async {
|
||||
_tester.start();
|
||||
registerDidStop(_tester.stop);
|
||||
});
|
||||
@@ -146,7 +146,7 @@ class _UntilNextFrame {
|
||||
static Future<void> wait() {
|
||||
if (_UntilNextFrame._completer == null) {
|
||||
_UntilNextFrame._completer = Completer<void>();
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
SchedulerBinding.instance!.addPostFrameCallback((_) {
|
||||
_UntilNextFrame._completer!.complete(null);
|
||||
_UntilNextFrame._completer = null;
|
||||
});
|
||||
@@ -167,7 +167,7 @@ class _Tester {
|
||||
TestGesture get gesture {
|
||||
return _gesture ??= TestGesture(
|
||||
dispatcher: (PointerEvent event) async {
|
||||
RendererBinding.instance.handlePointerEvent(event);
|
||||
RendererBinding.instance!.handlePointerEvent(event);
|
||||
},
|
||||
kind: PointerDeviceKind.mouse,
|
||||
);
|
||||
|
||||
@@ -935,7 +935,7 @@ double _computeAverage(String label, Iterable<double> values) {
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * <https://en.wikipedia.org/wiki/Standard_deviation>
|
||||
/// * https://en.wikipedia.org/wiki/Standard_deviation
|
||||
double _computeStandardDeviationForPopulation(String label, Iterable<double> population) {
|
||||
if (population.isEmpty) {
|
||||
throw StateError('$label: attempted to compute the standard deviation of empty population.');
|
||||
@@ -987,32 +987,12 @@ class _RecordingWidgetsBinding extends BindingBase
|
||||
SemanticsBinding,
|
||||
RendererBinding,
|
||||
WidgetsBinding {
|
||||
|
||||
@override
|
||||
void initInstances() {
|
||||
super.initInstances();
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
/// The singleton instance of this object.
|
||||
///
|
||||
/// Provides access to the features exposed by this class. The binding must
|
||||
/// be initialized before using this getter; this is typically done by calling
|
||||
/// [_RecordingWidgetsBinding.ensureInitialized].
|
||||
static _RecordingWidgetsBinding get instance => BindingBase.checkInstance(_instance);
|
||||
static _RecordingWidgetsBinding? _instance;
|
||||
|
||||
/// Returns an instance of the [_RecordingWidgetsBinding], creating and
|
||||
/// initializing it if necessary.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [WidgetsFlutterBinding.ensureInitialized], the equivalent in the widgets framework.
|
||||
/// Makes an instance of [_RecordingWidgetsBinding] the current binding.
|
||||
static _RecordingWidgetsBinding ensureInitialized() {
|
||||
if (_instance == null) {
|
||||
if (WidgetsBinding.instance == null) {
|
||||
_RecordingWidgetsBinding();
|
||||
}
|
||||
return instance;
|
||||
return WidgetsBinding.instance! as _RecordingWidgetsBinding;
|
||||
}
|
||||
|
||||
FrameRecorder? _recorder;
|
||||
|
||||
@@ -10,7 +10,8 @@ import 'package:integration_test/integration_test.dart';
|
||||
import 'package:macrobenchmarks/src/simple_scroll.dart';
|
||||
|
||||
void main() {
|
||||
final IntegrationTestWidgetsFlutterBinding binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
final IntegrationTestWidgetsFlutterBinding binding =
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized() as IntegrationTestWidgetsFlutterBinding;
|
||||
testWidgets(
|
||||
'Frame Counter and Input Delay for benchmarkLive',
|
||||
(WidgetTester tester) async {
|
||||
|
||||
@@ -10,8 +10,8 @@ import 'package:macrobenchmarks/main.dart';
|
||||
|
||||
Future<void> endOfAnimation() async {
|
||||
do {
|
||||
await SchedulerBinding.instance.endOfFrame;
|
||||
} while (SchedulerBinding.instance.hasScheduledFrame);
|
||||
await SchedulerBinding.instance!.endOfFrame;
|
||||
} while (SchedulerBinding.instance!.hasScheduledFrame);
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
|
||||
@@ -10,8 +10,8 @@ import 'package:macrobenchmarks/main.dart';
|
||||
|
||||
Future<void> endOfAnimation() async {
|
||||
do {
|
||||
await SchedulerBinding.instance.endOfFrame;
|
||||
} while (SchedulerBinding.instance.hasScheduledFrame);
|
||||
await SchedulerBinding.instance!.endOfFrame;
|
||||
} while (SchedulerBinding.instance!.hasScheduledFrame);
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
|
||||
@@ -44,24 +44,24 @@ Future<void> main() async {
|
||||
|
||||
// Wait for frame rendering to stabilize.
|
||||
for (int i = 0; i < 5; i++) {
|
||||
await SchedulerBinding.instance.endOfFrame;
|
||||
await SchedulerBinding.instance?.endOfFrame;
|
||||
}
|
||||
|
||||
final Stopwatch watch = Stopwatch();
|
||||
|
||||
print('flutter_test allElements benchmark... (${WidgetsBinding.instance.renderViewElement})');
|
||||
print('flutter_test allElements benchmark... (${WidgetsBinding.instance?.renderViewElement})');
|
||||
// Make sure we get enough elements to process for consistent benchmark runs
|
||||
int elementCount = collectAllElementsFrom(WidgetsBinding.instance.renderViewElement!, skipOffstage: false).length;
|
||||
int elementCount = collectAllElementsFrom(WidgetsBinding.instance!.renderViewElement!, skipOffstage: false).length;
|
||||
while (elementCount < 2458) {
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
elementCount = collectAllElementsFrom(WidgetsBinding.instance.renderViewElement!, skipOffstage: false).length;
|
||||
elementCount = collectAllElementsFrom(WidgetsBinding.instance!.renderViewElement!, skipOffstage: false).length;
|
||||
}
|
||||
print('element count: $elementCount');
|
||||
|
||||
watch.start();
|
||||
for (int i = 0; i < _kNumIters; i += 1) {
|
||||
final List<Element> allElements = collectAllElementsFrom(
|
||||
WidgetsBinding.instance.renderViewElement!,
|
||||
WidgetsBinding.instance!.renderViewElement!,
|
||||
skipOffstage: false,
|
||||
).toList();
|
||||
allElements.clear();
|
||||
|
||||
@@ -68,7 +68,7 @@ Future<void> main() async {
|
||||
|
||||
// Time how long each frame takes
|
||||
cpuWatch.reset();
|
||||
while (SchedulerBinding.instance.hasScheduledFrame) {
|
||||
while (SchedulerBinding.instance!.hasScheduledFrame) {
|
||||
await tester.pump();
|
||||
totalSubsequentFramesIterationCount += 1;
|
||||
}
|
||||
|
||||
@@ -33,18 +33,18 @@ Future<void> main() async {
|
||||
|
||||
final TestViewConfiguration big = TestViewConfiguration(
|
||||
size: const Size(360.0, 640.0),
|
||||
window: RendererBinding.instance.window,
|
||||
window: RendererBinding.instance?.window,
|
||||
);
|
||||
final TestViewConfiguration small = TestViewConfiguration(
|
||||
size: const Size(355.0, 635.0),
|
||||
window: RendererBinding.instance.window,
|
||||
window: RendererBinding.instance?.window,
|
||||
);
|
||||
final RenderView renderView = WidgetsBinding.instance.renderView;
|
||||
final RenderView? renderView = WidgetsBinding.instance?.renderView;
|
||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.benchmark;
|
||||
|
||||
watch.start();
|
||||
while (watch.elapsed < kBenchmarkTime) {
|
||||
renderView.configuration = iterations.isEven ? big : small;
|
||||
renderView?.configuration = iterations.isEven ? big : small;
|
||||
await tester.pumpBenchmark(Duration(milliseconds: iterations * 16));
|
||||
iterations += 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user