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
e9be230a
Unverified
Commit
e9be230a
authored
Mar 11, 2019
by
Michael Goderbauer
Committed by
GitHub
Mar 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deprecate profile() (#29054)
parent
c2f4386c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
28 deletions
+48
-28
isolates.dart
packages/flutter/lib/src/foundation/isolates.dart
+4
-2
profile.dart
packages/flutter/lib/src/foundation/profile.dart
+9
-3
object.dart
packages/flutter/lib/src/rendering/object.dart
+22
-10
binding.dart
packages/flutter/lib/src/scheduler/binding.dart
+4
-4
binding.dart
packages/flutter/lib/src/widgets/binding.dart
+8
-8
profile_test.dart
packages/flutter/test/foundation/profile_test.dart
+1
-1
No files found.
packages/flutter/lib/src/foundation/isolates.dart
View file @
e9be230a
...
@@ -8,7 +8,7 @@ import 'dart:isolate';
...
@@ -8,7 +8,7 @@ import 'dart:isolate';
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
import
'
profile
.dart'
;
import
'
constants
.dart'
;
/// Signature for the callback passed to [compute].
/// Signature for the callback passed to [compute].
///
///
...
@@ -45,7 +45,9 @@ typedef ComputeCallback<Q, R> = R Function(Q message);
...
@@ -45,7 +45,9 @@ typedef ComputeCallback<Q, R> = R Function(Q message);
/// The `debugLabel` argument can be specified to provide a name to add to the
/// The `debugLabel` argument can be specified to provide a name to add to the
/// [Timeline]. This is useful when profiling an application.
/// [Timeline]. This is useful when profiling an application.
Future
<
R
>
compute
<
Q
,
R
>(
ComputeCallback
<
Q
,
R
>
callback
,
Q
message
,
{
String
debugLabel
})
async
{
Future
<
R
>
compute
<
Q
,
R
>(
ComputeCallback
<
Q
,
R
>
callback
,
Q
message
,
{
String
debugLabel
})
async
{
profile
(()
{
debugLabel
??=
callback
.
toString
();
});
if
(!
kReleaseMode
)
{
debugLabel
??=
callback
.
toString
();
}
final
Flow
flow
=
Flow
.
begin
();
final
Flow
flow
=
Flow
.
begin
();
Timeline
.
startSync
(
'
$debugLabel
: start'
,
flow:
flow
);
Timeline
.
startSync
(
'
$debugLabel
: start'
,
flow:
flow
);
final
ReceivePort
resultPort
=
ReceivePort
();
final
ReceivePort
resultPort
=
ReceivePort
();
...
...
packages/flutter/lib/src/foundation/profile.dart
View file @
e9be230a
...
@@ -6,10 +6,16 @@ import 'dart:ui' show VoidCallback;
...
@@ -6,10 +6,16 @@ import 'dart:ui' show VoidCallback;
import
'constants.dart'
;
import
'constants.dart'
;
///
When running in profile mode (or debug mode), invoke the given function
.
///
DEPRECATED. `function` cannot be treeshaken out of release builds
.
///
///
/// In release mode, the function is not invoked.
/// Instead use:
// TODO(devoncarew): Going forward, we'll want the call to profile() to be tree-shaken out.
///
/// ```dart
/// if (!kReleaseMode) {
/// function();
/// }
/// ```
@Deprecated
(
'Use `if (!kReleaseMode) { function(); }` instead'
)
void
profile
(
VoidCallback
function
)
{
void
profile
(
VoidCallback
function
)
{
if
(
kReleaseMode
)
if
(
kReleaseMode
)
return
;
return
;
...
...
packages/flutter/lib/src/rendering/object.dart
View file @
e9be230a
...
@@ -749,9 +749,9 @@ class PipelineOwner {
...
@@ -749,9 +749,9 @@ class PipelineOwner {
///
///
/// See [RendererBinding] for an example of how this function is used.
/// See [RendererBinding] for an example of how this function is used.
void
flushLayout
()
{
void
flushLayout
()
{
profile
((
)
{
if
(!
kReleaseMode
)
{
Timeline
.
startSync
(
'Layout'
,
arguments:
timelineWhitelistArguments
);
Timeline
.
startSync
(
'Layout'
,
arguments:
timelineWhitelistArguments
);
}
);
}
assert
(()
{
assert
(()
{
_debugDoingLayout
=
true
;
_debugDoingLayout
=
true
;
return
true
;
return
true
;
...
@@ -771,9 +771,9 @@ class PipelineOwner {
...
@@ -771,9 +771,9 @@ class PipelineOwner {
_debugDoingLayout
=
false
;
_debugDoingLayout
=
false
;
return
true
;
return
true
;
}());
}());
profile
((
)
{
if
(!
kReleaseMode
)
{
Timeline
.
finishSync
();
Timeline
.
finishSync
();
}
);
}
}
}
}
}
...
@@ -809,14 +809,18 @@ class PipelineOwner {
...
@@ -809,14 +809,18 @@ class PipelineOwner {
/// Called as part of the rendering pipeline after [flushLayout] and before
/// Called as part of the rendering pipeline after [flushLayout] and before
/// [flushPaint].
/// [flushPaint].
void
flushCompositingBits
()
{
void
flushCompositingBits
()
{
profile
(()
{
Timeline
.
startSync
(
'Compositing bits'
);
});
if
(!
kReleaseMode
)
{
Timeline
.
startSync
(
'Compositing bits'
);
}
_nodesNeedingCompositingBitsUpdate
.
sort
((
RenderObject
a
,
RenderObject
b
)
=>
a
.
depth
-
b
.
depth
);
_nodesNeedingCompositingBitsUpdate
.
sort
((
RenderObject
a
,
RenderObject
b
)
=>
a
.
depth
-
b
.
depth
);
for
(
RenderObject
node
in
_nodesNeedingCompositingBitsUpdate
)
{
for
(
RenderObject
node
in
_nodesNeedingCompositingBitsUpdate
)
{
if
(
node
.
_needsCompositingBitsUpdate
&&
node
.
owner
==
this
)
if
(
node
.
_needsCompositingBitsUpdate
&&
node
.
owner
==
this
)
node
.
_updateCompositingBits
();
node
.
_updateCompositingBits
();
}
}
_nodesNeedingCompositingBitsUpdate
.
clear
();
_nodesNeedingCompositingBitsUpdate
.
clear
();
profile
(()
{
Timeline
.
finishSync
();
});
if
(!
kReleaseMode
)
{
Timeline
.
finishSync
();
}
}
}
List
<
RenderObject
>
_nodesNeedingPaint
=
<
RenderObject
>[];
List
<
RenderObject
>
_nodesNeedingPaint
=
<
RenderObject
>[];
...
@@ -837,7 +841,9 @@ class PipelineOwner {
...
@@ -837,7 +841,9 @@ class PipelineOwner {
///
///
/// See [RendererBinding] for an example of how this function is used.
/// See [RendererBinding] for an example of how this function is used.
void
flushPaint
()
{
void
flushPaint
()
{
profile
(()
{
Timeline
.
startSync
(
'Paint'
,
arguments:
timelineWhitelistArguments
);
});
if
(!
kReleaseMode
)
{
Timeline
.
startSync
(
'Paint'
,
arguments:
timelineWhitelistArguments
);
}
assert
(()
{
assert
(()
{
_debugDoingPaint
=
true
;
_debugDoingPaint
=
true
;
return
true
;
return
true
;
...
@@ -862,7 +868,9 @@ class PipelineOwner {
...
@@ -862,7 +868,9 @@ class PipelineOwner {
_debugDoingPaint
=
false
;
_debugDoingPaint
=
false
;
return
true
;
return
true
;
}());
}());
profile
(()
{
Timeline
.
finishSync
();
});
if
(!
kReleaseMode
)
{
Timeline
.
finishSync
();
}
}
}
}
}
...
@@ -937,7 +945,9 @@ class PipelineOwner {
...
@@ -937,7 +945,9 @@ class PipelineOwner {
void
flushSemantics
()
{
void
flushSemantics
()
{
if
(
_semanticsOwner
==
null
)
if
(
_semanticsOwner
==
null
)
return
;
return
;
profile
(()
{
Timeline
.
startSync
(
'Semantics'
);
});
if
(!
kReleaseMode
)
{
Timeline
.
startSync
(
'Semantics'
);
}
assert
(
_semanticsOwner
!=
null
);
assert
(
_semanticsOwner
!=
null
);
assert
(()
{
_debugDoingSemantics
=
true
;
return
true
;
}());
assert
(()
{
_debugDoingSemantics
=
true
;
return
true
;
}());
try
{
try
{
...
@@ -952,7 +962,9 @@ class PipelineOwner {
...
@@ -952,7 +962,9 @@ class PipelineOwner {
}
finally
{
}
finally
{
assert
(
_nodesNeedingSemantics
.
isEmpty
);
assert
(
_nodesNeedingSemantics
.
isEmpty
);
assert
(()
{
_debugDoingSemantics
=
false
;
return
true
;
}());
assert
(()
{
_debugDoingSemantics
=
false
;
return
true
;
}());
profile
(()
{
Timeline
.
finishSync
();
});
if
(!
kReleaseMode
)
{
Timeline
.
finishSync
();
}
}
}
}
}
}
}
...
...
packages/flutter/lib/src/scheduler/binding.dart
View file @
e9be230a
...
@@ -890,11 +890,11 @@ mixin SchedulerBinding on BindingBase, ServicesBinding {
...
@@ -890,11 +890,11 @@ mixin SchedulerBinding on BindingBase, ServicesBinding {
if
(
rawTimeStamp
!=
null
)
if
(
rawTimeStamp
!=
null
)
_lastRawTimeStamp
=
rawTimeStamp
;
_lastRawTimeStamp
=
rawTimeStamp
;
profile
((
)
{
if
(!
kReleaseMode
)
{
_profileFrameNumber
+=
1
;
_profileFrameNumber
+=
1
;
_profileFrameStopwatch
.
reset
();
_profileFrameStopwatch
.
reset
();
_profileFrameStopwatch
.
start
();
_profileFrameStopwatch
.
start
();
}
);
}
assert
(()
{
assert
(()
{
if
(
debugPrintBeginFrameBanner
||
debugPrintEndFrameBanner
)
{
if
(
debugPrintBeginFrameBanner
||
debugPrintEndFrameBanner
)
{
...
@@ -957,10 +957,10 @@ mixin SchedulerBinding on BindingBase, ServicesBinding {
...
@@ -957,10 +957,10 @@ mixin SchedulerBinding on BindingBase, ServicesBinding {
}
finally
{
}
finally
{
_schedulerPhase
=
SchedulerPhase
.
idle
;
_schedulerPhase
=
SchedulerPhase
.
idle
;
Timeline
.
finishSync
();
// end the Frame
Timeline
.
finishSync
();
// end the Frame
profile
((
)
{
if
(!
kReleaseMode
)
{
_profileFrameStopwatch
.
stop
();
_profileFrameStopwatch
.
stop
();
_profileFramePostEvent
();
_profileFramePostEvent
();
}
);
}
assert
(()
{
assert
(()
{
if
(
debugPrintEndFrameBanner
)
if
(
debugPrintEndFrameBanner
)
debugPrint
(
'▀'
*
_debugBanner
.
length
);
debugPrint
(
'▀'
*
_debugBanner
.
length
);
...
...
packages/flutter/lib/src/widgets/binding.dart
View file @
e9be230a
...
@@ -270,7 +270,7 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB
...
@@ -270,7 +270,7 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB
void
initServiceExtensions
()
{
void
initServiceExtensions
()
{
super
.
initServiceExtensions
();
super
.
initServiceExtensions
();
profile
((
)
{
if
(!
kReleaseMode
)
{
registerSignalServiceExtension
(
registerSignalServiceExtension
(
name:
'debugDumpApp'
,
name:
'debugDumpApp'
,
callback:
()
{
callback:
()
{
...
@@ -302,7 +302,7 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB
...
@@ -302,7 +302,7 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB
};
};
},
},
);
);
}
);
}
assert
(()
{
assert
(()
{
registerBoolServiceExtension
(
registerBoolServiceExtension
(
...
@@ -566,10 +566,10 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB
...
@@ -566,10 +566,10 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB
/// This is used by [WidgetsApp] to avoid reporting frames that aren't useful
/// This is used by [WidgetsApp] to avoid reporting frames that aren't useful
/// during startup as the "first frame".
/// during startup as the "first frame".
void
deferFirstFrameReport
()
{
void
deferFirstFrameReport
()
{
profile
((
)
{
if
(!
kReleaseMode
)
{
assert
(
_deferFirstFrameReportCount
>=
0
);
assert
(
_deferFirstFrameReportCount
>=
0
);
_deferFirstFrameReportCount
+=
1
;
_deferFirstFrameReportCount
+=
1
;
}
);
}
}
}
/// When called after [deferFirstFrameReport]: tell the framework to report
/// When called after [deferFirstFrameReport]: tell the framework to report
...
@@ -581,10 +581,10 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB
...
@@ -581,10 +581,10 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB
/// This is used by [WidgetsApp] to report when the first useful frame is
/// This is used by [WidgetsApp] to report when the first useful frame is
/// painted.
/// painted.
void
allowFirstFrameReport
()
{
void
allowFirstFrameReport
()
{
profile
((
)
{
if
(!
kReleaseMode
)
{
assert
(
_deferFirstFrameReportCount
>=
1
);
assert
(
_deferFirstFrameReportCount
>=
1
);
_deferFirstFrameReportCount
-=
1
;
_deferFirstFrameReportCount
-=
1
;
}
);
}
}
}
void
_handleBuildScheduled
()
{
void
_handleBuildScheduled
()
{
...
@@ -706,13 +706,13 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB
...
@@ -706,13 +706,13 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB
return
true
;
return
true
;
}());
}());
}
}
profile
((
)
{
if
(!
kReleaseMode
)
{
if
(
_needToReportFirstFrame
&&
_reportFirstFrame
)
{
if
(
_needToReportFirstFrame
&&
_reportFirstFrame
)
{
developer
.
Timeline
.
instantSync
(
'Widgets completed first useful frame'
);
developer
.
Timeline
.
instantSync
(
'Widgets completed first useful frame'
);
developer
.
postEvent
(
'Flutter.FirstFrame'
,
<
String
,
dynamic
>{});
developer
.
postEvent
(
'Flutter.FirstFrame'
,
<
String
,
dynamic
>{});
_needToReportFirstFrame
=
false
;
_needToReportFirstFrame
=
false
;
}
}
}
);
}
}
}
/// The [Element] that is at the root of the hierarchy (and which wraps the
/// The [Element] that is at the root of the hierarchy (and which wraps the
...
...
packages/flutter/test/foundation/profile_test.dart
View file @
e9be230a
...
@@ -10,7 +10,7 @@ void main() {
...
@@ -10,7 +10,7 @@ void main() {
// that the code in the `profile` closure is omitted in release mode.
// that the code in the `profile` closure is omitted in release mode.
test
(
'profile invokes its closure in debug or profile mode'
,
()
{
test
(
'profile invokes its closure in debug or profile mode'
,
()
{
int
count
=
0
;
int
count
=
0
;
profile
(()
{
profile
(()
{
// ignore: deprecated_member_use_from_same_package
count
++;
count
++;
});
});
// We run our tests in debug mode, so kReleaseMode will always evaluate to
// We run our tests in debug mode, so kReleaseMode will always evaluate to
...
...
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