Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
10bcddcc
Unverified
Commit
10bcddcc
authored
Oct 29, 2018
by
Jacob Richman
Committed by
GitHub
Oct 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option to track widget rebuilds and repaints from the Flutter inspector. (#23534)
parent
b722a744
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
853 additions
and
15 deletions
+853
-15
debug.dart
packages/flutter/lib/src/rendering/debug.dart
+23
-1
object.dart
packages/flutter/lib/src/rendering/object.dart
+2
-0
binding.dart
packages/flutter/lib/src/widgets/binding.dart
+5
-0
debug.dart
packages/flutter/lib/src/widgets/debug.dart
+20
-0
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+3
-0
widget_inspector.dart
packages/flutter/lib/src/widgets/widget_inspector.dart
+354
-12
service_extensions_test.dart
...ages/flutter/test/foundation/service_extensions_test.dart
+8
-2
widget_inspector_test.dart
packages/flutter/test/widgets/widget_inspector_test.dart
+438
-0
No files found.
packages/flutter/lib/src/rendering/debug.dart
View file @
10bcddcc
...
@@ -5,6 +5,8 @@
...
@@ -5,6 +5,8 @@
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/painting.dart'
;
import
'package:flutter/painting.dart'
;
import
'object.dart'
;
export
'package:flutter/foundation.dart'
show
debugPrint
;
export
'package:flutter/foundation.dart'
show
debugPrint
;
// Any changes to this file should be reflected in the debugAssertAllRenderVarsUnset()
// Any changes to this file should be reflected in the debugAssertAllRenderVarsUnset()
...
@@ -116,6 +118,25 @@ bool debugCheckIntrinsicSizes = false;
...
@@ -116,6 +118,25 @@ bool debugCheckIntrinsicSizes = false;
/// areas are being excessively repainted.
/// areas are being excessively repainted.
bool
debugProfilePaintsEnabled
=
false
;
bool
debugProfilePaintsEnabled
=
false
;
/// Signature for [debugOnProfilePaint] implementations.
typedef
ProfilePaintCallback
=
void
Function
(
RenderObject
renderObject
);
/// Callback invoked for every [RenderObject] painted each frame.
///
/// This callback is only invoked in debug builds.
///
/// See also:
///
/// * [debugProfilePaintsEnabled], which does something similar but adds
/// [dart:developer.Timeline] events instead of invoking a callback.
/// * [debugOnRebuildDirtyWidget], which does something similar for widgets
/// being built.
/// * [WidgetInspectorService], which uses the [debugOnProfilePaint]
/// callback to generate aggregate profile statistics describing what paints
/// occurred when the `ext.flutter.inspector.trackRepaintWidgets` service
/// extension is enabled.
ProfilePaintCallback
debugOnProfilePaint
;
/// Setting to true will cause all clipping effects from the layer tree to be
/// Setting to true will cause all clipping effects from the layer tree to be
/// ignored.
/// ignored.
///
///
...
@@ -205,7 +226,8 @@ bool debugAssertAllRenderVarsUnset(String reason, { bool debugCheckIntrinsicSize
...
@@ -205,7 +226,8 @@ bool debugAssertAllRenderVarsUnset(String reason, { bool debugCheckIntrinsicSize
debugPrintMarkNeedsPaintStacks
||
debugPrintMarkNeedsPaintStacks
||
debugPrintLayouts
||
debugPrintLayouts
||
debugCheckIntrinsicSizes
!=
debugCheckIntrinsicSizesOverride
||
debugCheckIntrinsicSizes
!=
debugCheckIntrinsicSizesOverride
||
debugProfilePaintsEnabled
)
{
debugProfilePaintsEnabled
||
debugOnProfilePaint
!=
null
)
{
throw
FlutterError
(
reason
);
throw
FlutterError
(
reason
);
}
}
return
true
;
return
true
;
...
...
packages/flutter/lib/src/rendering/object.dart
View file @
10bcddcc
...
@@ -161,6 +161,8 @@ class PaintingContext extends ClipContext {
...
@@ -161,6 +161,8 @@ class PaintingContext extends ClipContext {
assert
(()
{
assert
(()
{
if
(
debugProfilePaintsEnabled
)
if
(
debugProfilePaintsEnabled
)
Timeline
.
startSync
(
'
${child.runtimeType}
'
,
arguments:
timelineWhitelistArguments
);
Timeline
.
startSync
(
'
${child.runtimeType}
'
,
arguments:
timelineWhitelistArguments
);
if
(
debugOnProfilePaint
!=
null
)
debugOnProfilePaint
(
child
);
return
true
;
return
true
;
}());
}());
...
...
packages/flutter/lib/src/widgets/binding.dart
View file @
10bcddcc
...
@@ -711,6 +711,11 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB
...
@@ -711,6 +711,11 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB
@override
@override
Future
<
void
>
performReassemble
()
{
Future
<
void
>
performReassemble
()
{
assert
(()
{
WidgetInspectorService
.
instance
.
performReassemble
();
return
true
;
}());
deferFirstFrameReport
();
deferFirstFrameReport
();
if
(
renderViewElement
!=
null
)
if
(
renderViewElement
!=
null
)
buildOwner
.
reassemble
(
renderViewElement
);
buildOwner
.
reassemble
(
renderViewElement
);
...
...
packages/flutter/lib/src/widgets/debug.dart
View file @
10bcddcc
...
@@ -30,6 +30,26 @@ import 'table.dart';
...
@@ -30,6 +30,26 @@ import 'table.dart';
/// See also the discussion at [WidgetsBinding.drawFrame].
/// See also the discussion at [WidgetsBinding.drawFrame].
bool
debugPrintRebuildDirtyWidgets
=
false
;
bool
debugPrintRebuildDirtyWidgets
=
false
;
/// Signature for [debugOnRebuildDirtyWidget] implementations.
typedef
RebuildDirtyWidgetCallback
=
void
Function
(
Element
e
,
bool
builtOnce
);
/// Callback invoked for every dirty widget built each frame.
///
/// This callback is only invoked in debug builds.
///
/// See also:
///
/// * [debugPrintRebuildDirtyWidgets], which does something similar but logs
/// to the console instead of invoking a callback.
/// * [debugOnProfilePaint], which does something similar for [RenderObject]
/// painting.
/// * [WidgetInspectorService], which uses the [debugOnRebuildDirtyWidget]
/// callback to generate aggregate profile statistics describing which widget
/// rebuilds occurred when the
/// `ext.flutter.inspector.trackRebuildDirtyWidgets` service extension is
/// enabled.
RebuildDirtyWidgetCallback
debugOnRebuildDirtyWidget
;
/// Log all calls to [BuildOwner.buildScope].
/// Log all calls to [BuildOwner.buildScope].
///
///
/// Combined with [debugPrintScheduleBuildForStacks], this allows you to track
/// Combined with [debugPrintScheduleBuildForStacks], this allows you to track
...
...
packages/flutter/lib/src/widgets/framework.dart
View file @
10bcddcc
...
@@ -3514,6 +3514,9 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
...
@@ -3514,6 +3514,9 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
if
(!
_active
||
!
_dirty
)
if
(!
_active
||
!
_dirty
)
return
;
return
;
assert
(()
{
assert
(()
{
if
(
debugOnRebuildDirtyWidget
!=
null
)
{
debugOnRebuildDirtyWidget
(
this
,
_debugBuiltOnce
);
}
if
(
debugPrintRebuildDirtyWidgets
)
{
if
(
debugPrintRebuildDirtyWidgets
)
{
if
(!
_debugBuiltOnce
)
{
if
(!
_debugBuiltOnce
)
{
debugPrint
(
'Building
$this
'
);
debugPrint
(
'Building
$this
'
);
...
...
packages/flutter/lib/src/widgets/widget_inspector.dart
View file @
10bcddcc
This diff is collapsed.
Click to expand it.
packages/flutter/test/foundation/service_extensions_test.dart
View file @
10bcddcc
...
@@ -528,12 +528,18 @@ void main() {
...
@@ -528,12 +528,18 @@ void main() {
});
});
test
(
'Service extensions - posttest'
,
()
async
{
test
(
'Service extensions - posttest'
,
()
async
{
// See widget_inspector_test.dart for tests of the
15
ext.flutter.inspector
// See widget_inspector_test.dart for tests of the ext.flutter.inspector
// service extensions included in this count.
// service extensions included in this count.
int
widgetInspectorExtensionCount
=
15
;
if
(
WidgetInspectorService
.
instance
.
isWidgetCreationTracked
())
{
// Some inspector extensions are only exposed if widget creation locations
// are tracked.
widgetInspectorExtensionCount
+=
2
;
}
// If you add a service extension... TEST IT! :-)
// If you add a service extension... TEST IT! :-)
// ...then increment this number.
// ...then increment this number.
expect
(
binding
.
extensions
.
length
,
38
);
expect
(
binding
.
extensions
.
length
,
23
+
widgetInspectorExtensionCount
);
expect
(
console
,
isEmpty
);
expect
(
console
,
isEmpty
);
debugPrint
=
debugPrintThrottled
;
debugPrint
=
debugPrintThrottled
;
...
...
packages/flutter/test/widgets/widget_inspector_test.dart
View file @
10bcddcc
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment