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
cd0fbd32
Unverified
Commit
cd0fbd32
authored
Feb 28, 2020
by
Yegor
Committed by
GitHub
Feb 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve web benchmark error reporting (#51490)
parent
213027dd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
18 deletions
+85
-18
bench_build_material_checkbox.dart
...benchmarks/lib/src/web/bench_build_material_checkbox.dart
+9
-4
recorder.dart
dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart
+42
-1
web_benchmarks.dart
dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart
+28
-13
web_benchmarks.dart
dev/devicelab/lib/tasks/web_benchmarks.dart
+6
-0
No files found.
dev/benchmarks/macrobenchmarks/lib/src/web/bench_build_material_checkbox.dart
View file @
cd0fbd32
...
...
@@ -18,10 +18,15 @@ class BenchBuildMaterialCheckbox extends WidgetBuildRecorder {
@override
Widget
createWidget
()
{
return
Column
(
children:
List
<
Widget
>.
generate
(
10
,
(
int
i
)
{
return
_buildRow
();
}),
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Material
(
child:
Column
(
children:
List
<
Widget
>.
generate
(
10
,
(
int
i
)
{
return
_buildRow
();
}),
),
),
);
}
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart
View file @
cd0fbd32
...
...
@@ -218,6 +218,11 @@ abstract class WidgetRecorder extends Recorder implements _RecordingWidgetsBindi
}
}
@override
void
_onError
(
dynamic
error
,
StackTrace
stackTrace
)
{
_profileCompleter
.
completeError
(
error
,
stackTrace
);
}
@override
Future
<
Profile
>
run
()
{
final
_RecordingWidgetsBinding
binding
=
...
...
@@ -289,6 +294,11 @@ abstract class WidgetBuildRecorder extends Recorder implements _RecordingWidgets
}
}
@override
void
_onError
(
dynamic
error
,
StackTrace
stackTrace
)
{
_profileCompleter
.
completeError
(
error
,
stackTrace
);
}
@override
Future
<
Profile
>
run
()
{
final
_RecordingWidgetsBinding
binding
=
...
...
@@ -512,9 +522,19 @@ double _computeStandardDeviationForPopulation(Iterable<double> population) {
/// Implemented by recorders that use [_RecordingWidgetsBinding] to receive
/// frame life-cycle calls.
abstract
class
_RecordingWidgetsBindingListener
{
/// Whether the binding should continue pumping frames.
bool
_shouldContinue
();
/// Called just before calling [SchedulerBinding.handleDrawFrame].
void
_frameWillDraw
();
/// Called immediately after calling [SchedulerBinding.handleDrawFrame].
void
_frameDidDraw
();
/// Reports an error.
///
/// The implementation is expected to halt benchmark execution as soon as possible.
void
_onError
(
dynamic
error
,
StackTrace
stackTrace
);
}
/// A variant of [WidgetsBinding] that collaborates with a [Recorder] to decide
...
...
@@ -543,8 +563,20 @@ class _RecordingWidgetsBinding extends BindingBase
}
_RecordingWidgetsBindingListener
_listener
;
bool
_hasErrored
=
false
;
void
_beginRecording
(
_RecordingWidgetsBindingListener
recorder
,
Widget
widget
)
{
final
FlutterExceptionHandler
originalOnError
=
FlutterError
.
onError
;
// Fail hard and fast on errors. Benchmarks should not have any errors.
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
if
(
_hasErrored
)
{
return
;
}
_listener
.
_onError
(
details
.
exception
,
details
.
stack
);
_hasErrored
=
true
;
originalOnError
(
details
);
};
_listener
=
recorder
;
runApp
(
widget
);
}
...
...
@@ -555,19 +587,28 @@ class _RecordingWidgetsBinding extends BindingBase
@override
void
handleBeginFrame
(
Duration
rawTimeStamp
)
{
// Don't keep on truckin' if there's an error.
if
(
_hasErrored
)
{
return
;
}
_benchmarkStopped
=
!
_listener
.
_shouldContinue
();
super
.
handleBeginFrame
(
rawTimeStamp
);
}
@override
void
scheduleFrame
()
{
if
(!
_benchmarkStopped
)
{
// Don't keep on truckin' if there's an error.
if
(!
_benchmarkStopped
&&
!
_hasErrored
)
{
super
.
scheduleFrame
();
}
}
@override
void
handleDrawFrame
()
{
// Don't keep on truckin' if there's an error.
if
(
_hasErrored
)
{
return
;
}
_listener
.
_frameWillDraw
();
super
.
handleDrawFrame
();
_listener
.
_frameDidDraw
();
...
...
dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart
View file @
cd0fbd32
...
...
@@ -63,23 +63,38 @@ Future<void> _runBenchmark(String benchmarkName) async {
}
final
Recorder
recorder
=
recorderFactory
();
final
Profile
profile
=
await
recorder
.
run
();
if
(!
isInManualMode
)
{
final
html
.
HttpRequest
request
=
await
html
.
HttpRequest
.
request
(
'/profile-data'
,
try
{
final
Profile
profile
=
await
recorder
.
run
();
if
(!
isInManualMode
)
{
final
html
.
HttpRequest
request
=
await
html
.
HttpRequest
.
request
(
'/profile-data'
,
method:
'POST'
,
mimeType:
'application/json'
,
sendData:
json
.
encode
(
profile
.
toJson
()),
);
if
(
request
.
status
!=
200
)
{
throw
Exception
(
'Failed to report profile data to benchmark server. '
'The server responded with status code
${request.status}
.'
);
}
}
else
{
print
(
profile
);
}
}
catch
(
error
,
stackTrace
)
{
if
(
isInManualMode
)
{
rethrow
;
}
await
html
.
HttpRequest
.
request
(
'/on-error'
,
method:
'POST'
,
mimeType:
'application/json'
,
sendData:
json
.
encode
(
profile
.
toJson
()),
sendData:
json
.
encode
(<
String
,
dynamic
>{
'error'
:
'
$error
'
,
'stackTrace'
:
'
$stackTrace
'
,
}),
);
if
(
request
.
status
!=
200
)
{
throw
Exception
(
'Failed to report profile data to benchmark server. '
'The server responded with status code
${request.status}
.'
);
}
}
else
{
print
(
profile
);
}
}
...
...
dev/devicelab/lib/tasks/web_benchmarks.dart
View file @
cd0fbd32
...
...
@@ -53,6 +53,12 @@ Future<TaskResult> runWebBenchmark({ @required bool useCanvasKit }) async {
}
collectedProfiles
.
add
(
profile
);
return
Response
.
ok
(
'Profile received'
);
}
else
if
(
request
.
requestedUri
.
path
.
endsWith
(
'/on-error'
))
{
final
Map
<
String
,
dynamic
>
errorDetails
=
json
.
decode
(
await
request
.
readAsString
())
as
Map
<
String
,
dynamic
>;
server
.
close
();
// Keep the stack trace as a string. It's thrown in the browser, not this Dart VM.
profileData
.
completeError
(
'
${errorDetails['error']}
\n
${errorDetails['stackTrace']}
'
);
return
Response
.
ok
(
''
);
}
else
if
(
request
.
requestedUri
.
path
.
endsWith
(
'/next-benchmark'
))
{
if
(
benchmarks
==
null
)
{
benchmarks
=
(
json
.
decode
(
await
request
.
readAsString
())
as
List
<
dynamic
>).
cast
<
String
>();
...
...
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