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
ce6b330a
Commit
ce6b330a
authored
Dec 14, 2015
by
Devon Carew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
expose flutter debug functionality using VM service extensions
parent
9ad94220
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
1 deletion
+72
-1
binding.dart
packages/flutter/lib/src/rendering/binding.dart
+1
-0
debug.dart
packages/flutter/lib/src/rendering/debug.dart
+71
-1
No files found.
packages/flutter/lib/src/rendering/binding.dart
View file @
ce6b330a
...
...
@@ -25,6 +25,7 @@ abstract class Renderer extends Scheduler
ui
.
window
.
onMetricsChanged
=
handleMetricsChanged
;
initRenderView
();
addPersistentFrameCallback
(
_handlePersistentFrameCallback
);
initServiceExtensions
();
}
static
Renderer
_instance
;
...
...
packages/flutter/lib/src/rendering/debug.dart
View file @
ce6b330a
...
...
@@ -2,11 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
;
import
'dart:async'
;
import
'dart:collection'
;
import
'dart:convert'
show
JSON
;
import
'dart:developer'
;
import
'dart:ui'
as
ui
;
import
'package:flutter/painting.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
/// Causes each RenderBox to paint a box around its bounds.
...
...
@@ -54,6 +57,73 @@ List<String> debugDescribeTransform(Matrix4 transform) {
return
matrix
;
}
bool
_extensionsInitialized
=
false
;
void
initServiceExtensions
(
)
{
if
(
_extensionsInitialized
)
return
;
registerExtension
(
'flutter'
,
_flutter
);
// TODO: Expose debugDumpApp().
// TODO: Expose StatisticsOverlay.
registerExtension
(
'flutter.debugPaint'
,
_debugPaint
);
registerExtension
(
'flutter.timeDilation'
,
_timeDilation
);
_extensionsInitialized
=
true
;
// Emit an info level log message; this tells the debugger that the Flutter
// service extensions are registered.
log
(
'Flutter initialized'
,
name:
'flutter'
,
level:
800
);
}
/// Just respond to the request. Clients can use the existence of this call to
/// know that the debug client is a Flutter app.
Future
<
ServiceExtensionResponse
>
_flutter
(
String
method
,
Map
parameters
)
{
String
result
=
JSON
.
encode
({
'type'
:
'_extensionType'
,
'method'
:
method
});
return
new
Future
.
value
(
new
ServiceExtensionResponse
.
result
(
result
));
}
/// Toggle the [debugPaintSizeEnabled] setting.
Future
<
ServiceExtensionResponse
>
_debugPaint
(
String
method
,
Map
parameters
)
{
if
(
parameters
.
containsKey
(
'enabled'
))
{
// TODO: This is a work around for a VM bug: sdk/25208 - all params are
// coerced to strings.
// bool enabled = parameters['enabled'] == true;
debugPaintSizeEnabled
=
parameters
[
'enabled'
].
toString
()
==
'true'
;
// TODO: How to cause a redraw?
}
String
result
=
JSON
.
encode
({
'type'
:
'_extensionType'
,
'method'
:
method
,
'enabled'
:
debugPaintSizeEnabled
});
return
new
Future
.
value
(
new
ServiceExtensionResponse
.
result
(
result
));
}
/// Manipulate the scheduler's [timeDilation] field.
Future
<
ServiceExtensionResponse
>
_timeDilation
(
String
method
,
Map
parameters
)
{
if
(
parameters
.
containsKey
(
'timeDilation'
))
{
// TODO: Workaround for https://github.com/dart-lang/sdk/issues/25208.
dynamic
param
=
parameters
[
'timeDilation'
];
if
(
param
is
String
)
{
param
=
double
.
parse
(
param
);
}
else
if
(
param
is
num
)
{
param
=
param
.
toDouble
();
}
timeDilation
=
param
;
}
else
{
timeDilation
=
1.0
;
}
String
result
=
JSON
.
encode
({
'type'
:
'_extensionType'
,
'method'
:
method
,
'timeDilation'
:
'
${timeDilation}
'
});
return
new
Future
.
value
(
new
ServiceExtensionResponse
.
result
(
result
));
}
/// Prints a message to the console, which you can access using the "flutter"
/// tool's "logs" command ("flutter logs").
///
...
...
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