mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Remove obsolete performance analysis tools. (#147663)
We're unlikely to support these reliably going forward.
This commit is contained in:
parent
74771f12af
commit
db4dfa0dde
@ -563,8 +563,6 @@ class _CupertinoAppState extends State<CupertinoApp> {
|
||||
localeListResolutionCallback: widget.localeListResolutionCallback,
|
||||
supportedLocales: widget.supportedLocales,
|
||||
showPerformanceOverlay: widget.showPerformanceOverlay,
|
||||
checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages,
|
||||
checkerboardOffscreenLayers: widget.checkerboardOffscreenLayers,
|
||||
showSemanticsDebugger: widget.showSemanticsDebugger,
|
||||
debugShowCheckedModeBanner: widget.debugShowCheckedModeBanner,
|
||||
inspectorSelectButtonBuilder: _inspectorSelectButtonBuilder,
|
||||
@ -599,8 +597,6 @@ class _CupertinoAppState extends State<CupertinoApp> {
|
||||
localeListResolutionCallback: widget.localeListResolutionCallback,
|
||||
supportedLocales: widget.supportedLocales,
|
||||
showPerformanceOverlay: widget.showPerformanceOverlay,
|
||||
checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages,
|
||||
checkerboardOffscreenLayers: widget.checkerboardOffscreenLayers,
|
||||
showSemanticsDebugger: widget.showSemanticsDebugger,
|
||||
debugShowCheckedModeBanner: widget.debugShowCheckedModeBanner,
|
||||
inspectorSelectButtonBuilder: _inspectorSelectButtonBuilder,
|
||||
|
||||
@ -1028,8 +1028,6 @@ class _MaterialAppState extends State<MaterialApp> {
|
||||
localeListResolutionCallback: widget.localeListResolutionCallback,
|
||||
supportedLocales: widget.supportedLocales,
|
||||
showPerformanceOverlay: widget.showPerformanceOverlay,
|
||||
checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages,
|
||||
checkerboardOffscreenLayers: widget.checkerboardOffscreenLayers,
|
||||
showSemanticsDebugger: widget.showSemanticsDebugger,
|
||||
debugShowCheckedModeBanner: widget.debugShowCheckedModeBanner,
|
||||
inspectorSelectButtonBuilder: _inspectorSelectButtonBuilder,
|
||||
@ -1064,8 +1062,6 @@ class _MaterialAppState extends State<MaterialApp> {
|
||||
localeListResolutionCallback: widget.localeListResolutionCallback,
|
||||
supportedLocales: widget.supportedLocales,
|
||||
showPerformanceOverlay: widget.showPerformanceOverlay,
|
||||
checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages,
|
||||
checkerboardOffscreenLayers: widget.checkerboardOffscreenLayers,
|
||||
showSemanticsDebugger: widget.showSemanticsDebugger,
|
||||
debugShowCheckedModeBanner: widget.debugShowCheckedModeBanner,
|
||||
inspectorSelectButtonBuilder: _inspectorSelectButtonBuilder,
|
||||
|
||||
@ -1014,9 +1014,6 @@ class PerformanceOverlayLayer extends Layer {
|
||||
PerformanceOverlayLayer({
|
||||
required Rect overlayRect,
|
||||
required this.optionsMask,
|
||||
required this.rasterizerThreshold,
|
||||
required this.checkerboardRasterCacheImages,
|
||||
required this.checkerboardOffscreenLayers,
|
||||
}) : _overlayRect = overlayRect;
|
||||
|
||||
/// The rectangle in this layer's coordinate system that the overlay should occupy.
|
||||
@ -1036,40 +1033,9 @@ class PerformanceOverlayLayer extends Layer {
|
||||
/// [PerformanceOverlayOption] to enable.
|
||||
final int optionsMask;
|
||||
|
||||
/// The rasterizer threshold is an integer specifying the number of frame
|
||||
/// intervals that the rasterizer must miss before it decides that the frame
|
||||
/// is suitable for capturing an SkPicture trace for further analysis.
|
||||
final int rasterizerThreshold;
|
||||
|
||||
/// Whether the raster cache should checkerboard cached entries.
|
||||
///
|
||||
/// The compositor can sometimes decide to cache certain portions of the
|
||||
/// widget hierarchy. Such portions typically don't change often from frame to
|
||||
/// frame and are expensive to render. This can speed up overall rendering. However,
|
||||
/// there is certain upfront cost to constructing these cache entries. And, if
|
||||
/// the cache entries are not used very often, this cost may not be worth the
|
||||
/// speedup in rendering of subsequent frames. If the developer wants to be certain
|
||||
/// that populating the raster cache is not causing stutters, this option can be
|
||||
/// set. Depending on the observations made, hints can be provided to the compositor
|
||||
/// that aid it in making better decisions about caching.
|
||||
final bool checkerboardRasterCacheImages;
|
||||
|
||||
/// Whether the compositor should checkerboard layers that are rendered to offscreen
|
||||
/// bitmaps. This can be useful for debugging rendering performance.
|
||||
///
|
||||
/// Render target switches are caused by using opacity layers (via a [FadeTransition] or
|
||||
/// [Opacity] widget), clips, shader mask layers, etc. Selecting a new render target
|
||||
/// and merging it with the rest of the scene has a performance cost. This can sometimes
|
||||
/// be avoided by using equivalent widgets that do not require these layers (for example,
|
||||
/// replacing an [Opacity] widget with an [widgets.Image] using a [BlendMode]).
|
||||
final bool checkerboardOffscreenLayers;
|
||||
|
||||
@override
|
||||
void addToScene(ui.SceneBuilder builder) {
|
||||
builder.addPerformanceOverlay(optionsMask, overlayRect);
|
||||
builder.setRasterizerTracingThreshold(rasterizerThreshold);
|
||||
builder.setCheckerboardRasterCacheImages(checkerboardRasterCacheImages);
|
||||
builder.setCheckerboardOffscreenLayers(checkerboardOffscreenLayers);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -63,13 +63,7 @@ class RenderPerformanceOverlay extends RenderBox {
|
||||
/// Creates a performance overlay render object.
|
||||
RenderPerformanceOverlay({
|
||||
int optionsMask = 0,
|
||||
int rasterizerThreshold = 0,
|
||||
bool checkerboardRasterCacheImages = false,
|
||||
bool checkerboardOffscreenLayers = false,
|
||||
}) : _optionsMask = optionsMask,
|
||||
_rasterizerThreshold = rasterizerThreshold,
|
||||
_checkerboardRasterCacheImages = checkerboardRasterCacheImages,
|
||||
_checkerboardOffscreenLayers = checkerboardOffscreenLayers;
|
||||
}) : _optionsMask = optionsMask;
|
||||
|
||||
/// The mask is created by shifting 1 by the index of the specific
|
||||
/// [PerformanceOverlayOption] to enable.
|
||||
@ -83,41 +77,6 @@ class RenderPerformanceOverlay extends RenderBox {
|
||||
markNeedsPaint();
|
||||
}
|
||||
|
||||
/// The rasterizer threshold is an integer specifying the number of frame
|
||||
/// intervals that the rasterizer must miss before it decides that the frame
|
||||
/// is suitable for capturing an SkPicture trace for further analysis.
|
||||
int get rasterizerThreshold => _rasterizerThreshold;
|
||||
int _rasterizerThreshold;
|
||||
set rasterizerThreshold(int value) {
|
||||
if (value == _rasterizerThreshold) {
|
||||
return;
|
||||
}
|
||||
_rasterizerThreshold = value;
|
||||
markNeedsPaint();
|
||||
}
|
||||
|
||||
/// Whether the raster cache should checkerboard cached entries.
|
||||
bool get checkerboardRasterCacheImages => _checkerboardRasterCacheImages;
|
||||
bool _checkerboardRasterCacheImages;
|
||||
set checkerboardRasterCacheImages(bool value) {
|
||||
if (value == _checkerboardRasterCacheImages) {
|
||||
return;
|
||||
}
|
||||
_checkerboardRasterCacheImages = value;
|
||||
markNeedsPaint();
|
||||
}
|
||||
|
||||
/// Whether the compositor should checkerboard layers rendered to offscreen bitmaps.
|
||||
bool get checkerboardOffscreenLayers => _checkerboardOffscreenLayers;
|
||||
bool _checkerboardOffscreenLayers;
|
||||
set checkerboardOffscreenLayers(bool value) {
|
||||
if (value == _checkerboardOffscreenLayers) {
|
||||
return;
|
||||
}
|
||||
_checkerboardOffscreenLayers = value;
|
||||
markNeedsPaint();
|
||||
}
|
||||
|
||||
@override
|
||||
bool get sizedByParent => true;
|
||||
|
||||
@ -170,9 +129,6 @@ class RenderPerformanceOverlay extends RenderBox {
|
||||
context.addLayer(PerformanceOverlayLayer(
|
||||
overlayRect: Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height),
|
||||
optionsMask: optionsMask,
|
||||
rasterizerThreshold: rasterizerThreshold,
|
||||
checkerboardRasterCacheImages: checkerboardRasterCacheImages,
|
||||
checkerboardOffscreenLayers: checkerboardOffscreenLayers,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -330,8 +330,6 @@ class WidgetsApp extends StatefulWidget {
|
||||
this.localeResolutionCallback,
|
||||
this.supportedLocales = const <Locale>[Locale('en', 'US')],
|
||||
this.showPerformanceOverlay = false,
|
||||
this.checkerboardRasterCacheImages = false,
|
||||
this.checkerboardOffscreenLayers = false,
|
||||
this.showSemanticsDebugger = false,
|
||||
this.debugShowWidgetInspector = false,
|
||||
this.debugShowCheckedModeBanner = true,
|
||||
@ -430,8 +428,6 @@ class WidgetsApp extends StatefulWidget {
|
||||
this.localeResolutionCallback,
|
||||
this.supportedLocales = const <Locale>[Locale('en', 'US')],
|
||||
this.showPerformanceOverlay = false,
|
||||
this.checkerboardRasterCacheImages = false,
|
||||
this.checkerboardOffscreenLayers = false,
|
||||
this.showSemanticsDebugger = false,
|
||||
this.debugShowWidgetInspector = false,
|
||||
this.debugShowCheckedModeBanner = true,
|
||||
@ -1011,16 +1007,6 @@ class WidgetsApp extends StatefulWidget {
|
||||
/// * <https://flutter.dev/debugging/#performance-overlay>
|
||||
final bool showPerformanceOverlay;
|
||||
|
||||
/// Checkerboards raster cache images.
|
||||
///
|
||||
/// See [PerformanceOverlay.checkerboardRasterCacheImages].
|
||||
final bool checkerboardRasterCacheImages;
|
||||
|
||||
/// Checkerboards layers rendered to offscreen bitmaps.
|
||||
///
|
||||
/// See [PerformanceOverlay.checkerboardOffscreenLayers].
|
||||
final bool checkerboardOffscreenLayers;
|
||||
|
||||
/// Turns on an overlay that shows the accessibility information
|
||||
/// reported by the framework.
|
||||
final bool showSemanticsDebugger;
|
||||
@ -1740,25 +1726,11 @@ class _WidgetsAppState extends State<WidgetsApp> with WidgetsBindingObserver {
|
||||
);
|
||||
}
|
||||
|
||||
PerformanceOverlay? performanceOverlay;
|
||||
// We need to push a performance overlay if any of the display or checkerboarding
|
||||
// options are set.
|
||||
if (widget.showPerformanceOverlay || WidgetsApp.showPerformanceOverlayOverride) {
|
||||
performanceOverlay = PerformanceOverlay.allEnabled(
|
||||
checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages,
|
||||
checkerboardOffscreenLayers: widget.checkerboardOffscreenLayers,
|
||||
);
|
||||
} else if (widget.checkerboardRasterCacheImages || widget.checkerboardOffscreenLayers) {
|
||||
performanceOverlay = PerformanceOverlay(
|
||||
checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages,
|
||||
checkerboardOffscreenLayers: widget.checkerboardOffscreenLayers,
|
||||
);
|
||||
}
|
||||
if (performanceOverlay != null) {
|
||||
result = Stack(
|
||||
children: <Widget>[
|
||||
result,
|
||||
Positioned(top: 0.0, left: 0.0, right: 0.0, child: performanceOverlay),
|
||||
Positioned(top: 0.0, left: 0.0, right: 0.0, child: PerformanceOverlay.allEnabled()),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@ -22,27 +22,16 @@ import 'framework.dart';
|
||||
/// [MaterialApp.showPerformanceOverlay] or [WidgetsApp.showPerformanceOverlay]
|
||||
/// to true.
|
||||
class PerformanceOverlay extends LeafRenderObjectWidget {
|
||||
// TODO(abarth): We should have a page on the web site with a screenshot and
|
||||
// an explanation of all the various readouts.
|
||||
|
||||
/// Create a performance overlay that only displays specific statistics. The
|
||||
/// mask is created by shifting 1 by the index of the specific
|
||||
/// [PerformanceOverlayOption] to enable.
|
||||
const PerformanceOverlay({
|
||||
super.key,
|
||||
this.optionsMask = 0,
|
||||
this.rasterizerThreshold = 0,
|
||||
this.checkerboardRasterCacheImages = false,
|
||||
this.checkerboardOffscreenLayers = false,
|
||||
});
|
||||
|
||||
/// Create a performance overlay that displays all available statistics.
|
||||
PerformanceOverlay.allEnabled({
|
||||
super.key,
|
||||
this.rasterizerThreshold = 0,
|
||||
this.checkerboardRasterCacheImages = false,
|
||||
this.checkerboardOffscreenLayers = false,
|
||||
}) : optionsMask =
|
||||
PerformanceOverlay.allEnabled({ super.key }) : optionsMask =
|
||||
1 << PerformanceOverlayOption.displayRasterizerStatistics.index |
|
||||
1 << PerformanceOverlayOption.visualizeRasterizerStatistics.index |
|
||||
1 << PerformanceOverlayOption.displayEngineStatistics.index |
|
||||
@ -52,71 +41,13 @@ class PerformanceOverlay extends LeafRenderObjectWidget {
|
||||
/// [PerformanceOverlayOption] to enable.
|
||||
final int optionsMask;
|
||||
|
||||
/// The rasterizer threshold is an integer specifying the number of frame
|
||||
/// intervals that the rasterizer must miss before it decides that the frame
|
||||
/// is suitable for capturing an SkPicture trace for further analysis.
|
||||
///
|
||||
/// For example, if you want a trace of all pictures that could not be
|
||||
/// rendered by the rasterizer within the frame boundary (and hence caused
|
||||
/// jank), specify 1. Specifying 2 will trace all pictures that took more
|
||||
/// than 2 frame intervals to render. Adjust this value to only capture
|
||||
/// the particularly expensive pictures while skipping the others. Specifying
|
||||
/// 0 disables all capture.
|
||||
///
|
||||
/// Captured traces are placed on your device in the application documents
|
||||
/// directory in this form "trace_<collection_time>.skp". These can
|
||||
/// be viewed in the Skia debugger.
|
||||
///
|
||||
/// Notes:
|
||||
/// The rasterizer only takes into account the time it took to render
|
||||
/// the already constructed picture. This include the Skia calls (which is
|
||||
/// also why an SkPicture trace is generated) but not any of the time spent in
|
||||
/// dart to construct that picture. To profile that part of your code, use
|
||||
/// the instrumentation available in observatory.
|
||||
///
|
||||
/// To decide what threshold interval to use, count the number of horizontal
|
||||
/// lines displayed in the performance overlay for the rasterizer (not the
|
||||
/// engine). That should give an idea of how often frames are skipped (and by
|
||||
/// how many frame intervals).
|
||||
final int rasterizerThreshold;
|
||||
|
||||
/// Whether the raster cache should checkerboard cached entries.
|
||||
///
|
||||
/// The compositor can sometimes decide to cache certain portions of the
|
||||
/// widget hierarchy. Such portions typically don't change often from frame to
|
||||
/// frame and are expensive to render. This can speed up overall rendering. However,
|
||||
/// there is certain upfront cost to constructing these cache entries. And, if
|
||||
/// the cache entries are not used very often, this cost may not be worth the
|
||||
/// speedup in rendering of subsequent frames. If the developer wants to be certain
|
||||
/// that populating the raster cache is not causing stutters, this option can be
|
||||
/// set. Depending on the observations made, hints can be provided to the compositor
|
||||
/// that aid it in making better decisions about caching.
|
||||
final bool checkerboardRasterCacheImages;
|
||||
|
||||
/// Whether the compositor should checkerboard layers that are rendered to offscreen
|
||||
/// bitmaps. This can be useful for debugging rendering performance.
|
||||
///
|
||||
/// Render target switches are caused by using opacity layers (via a [FadeTransition] or
|
||||
/// [Opacity] widget), clips, shader mask layers, etc. Selecting a new render target
|
||||
/// and merging it with the rest of the scene has a performance cost. This can sometimes
|
||||
/// be avoided by using equivalent widgets that do not require these layers (for example,
|
||||
/// replacing an [Opacity] widget with an [widgets.Image] using a [BlendMode]).
|
||||
final bool checkerboardOffscreenLayers;
|
||||
|
||||
@override
|
||||
RenderPerformanceOverlay createRenderObject(BuildContext context) => RenderPerformanceOverlay(
|
||||
optionsMask: optionsMask,
|
||||
rasterizerThreshold: rasterizerThreshold,
|
||||
checkerboardRasterCacheImages: checkerboardRasterCacheImages,
|
||||
checkerboardOffscreenLayers: checkerboardOffscreenLayers,
|
||||
);
|
||||
|
||||
@override
|
||||
void updateRenderObject(BuildContext context, RenderPerformanceOverlay renderObject) {
|
||||
renderObject
|
||||
..optionsMask = optionsMask
|
||||
..rasterizerThreshold = rasterizerThreshold
|
||||
..checkerboardRasterCacheImages = checkerboardRasterCacheImages
|
||||
..checkerboardOffscreenLayers = checkerboardOffscreenLayers;
|
||||
renderObject.optionsMask = optionsMask;
|
||||
}
|
||||
}
|
||||
|
||||
@ -429,9 +429,6 @@ void main() {
|
||||
final PerformanceOverlayLayer layer = PerformanceOverlayLayer(
|
||||
overlayRect: Rect.zero,
|
||||
optionsMask: 0,
|
||||
rasterizerThreshold: 0,
|
||||
checkerboardRasterCacheImages: false,
|
||||
checkerboardOffscreenLayers: false,
|
||||
);
|
||||
checkNeedsAddToScene(layer, () {
|
||||
layer.overlayRect = unitRect;
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/src/rendering/performance_overlay.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
@ -11,30 +10,4 @@ void main() {
|
||||
await tester.pumpWidget(const PerformanceOverlay());
|
||||
await tester.pumpWidget(PerformanceOverlay.allEnabled());
|
||||
});
|
||||
|
||||
testWidgets('update widget field checkerboardRasterCacheImages',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(const PerformanceOverlay());
|
||||
await tester.pumpWidget(
|
||||
const PerformanceOverlay(checkerboardRasterCacheImages: true));
|
||||
final Finder finder = find.byType(PerformanceOverlay);
|
||||
expect(
|
||||
tester
|
||||
.renderObject<RenderPerformanceOverlay>(finder)
|
||||
.checkerboardRasterCacheImages,
|
||||
true);
|
||||
});
|
||||
|
||||
testWidgets('update widget field checkerboardOffscreenLayers',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(const PerformanceOverlay());
|
||||
await tester.pumpWidget(
|
||||
const PerformanceOverlay(checkerboardOffscreenLayers: true));
|
||||
final Finder finder = find.byType(PerformanceOverlay);
|
||||
expect(
|
||||
tester
|
||||
.renderObject<RenderPerformanceOverlay>(finder)
|
||||
.checkerboardOffscreenLayers,
|
||||
true);
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user