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
c5251cdc
Unverified
Commit
c5251cdc
authored
Dec 15, 2018
by
Stanislav Baranov
Committed by
GitHub
Dec 15, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Flutter tool support for automatic saving of JIT compilation trace (#25301)
parent
30fb97be
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
83 additions
and
1 deletion
+83
-1
binding.dart
packages/flutter/lib/src/foundation/binding.dart
+9
-0
service_extensions_test.dart
...ages/flutter/test/foundation/service_extensions_test.dart
+10
-1
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+19
-0
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+33
-0
run_cold.dart
packages/flutter_tools/lib/src/run_cold.dart
+2
-0
run_hot.dart
packages/flutter_tools/lib/src/run_hot.dart
+2
-0
vmservice.dart
packages/flutter_tools/lib/src/vmservice.dart
+8
-0
No files found.
packages/flutter/lib/src/foundation/binding.dart
View file @
c5251cdc
...
...
@@ -6,6 +6,7 @@ import 'dart:async';
import
'dart:convert'
show
json
;
import
'dart:developer'
as
developer
;
import
'dart:io'
show
exit
;
import
'dart:ui'
show
dumpCompilationTrace
;
import
'package:meta/meta.dart'
;
...
...
@@ -117,6 +118,14 @@ abstract class BindingBase {
name:
'exit'
,
callback:
_exitApplication
,
);
registerServiceExtension
(
name:
'dumpCompilationTrace'
,
callback:
(
Map
<
String
,
String
>
parameters
)
async
{
return
<
String
,
dynamic
>
{
'value'
:
dumpCompilationTrace
(),
};
}
);
}
assert
(()
{
...
...
packages/flutter/test/foundation/service_extensions_test.dart
View file @
c5251cdc
...
...
@@ -527,6 +527,15 @@ void main() {
expect
(
binding
.
frameScheduled
,
isFalse
);
});
test
(
'Service extensions - dumpCompilationTrace'
,
()
async
{
Map
<
String
,
dynamic
>
result
;
result
=
await
binding
.
testExtension
(
'dumpCompilationTrace'
,
<
String
,
String
>{});
final
String
trace
=
String
.
fromCharCodes
(
result
[
'value'
]);
expect
(
trace
,
contains
(
'dart:core,Object,Object.
\n
'
));
expect
(
trace
,
contains
(
'package:test_api/test_api.dart,::,test
\n
'
));
expect
(
trace
,
contains
(
'service_extensions_test.dart,::,main
\n
'
));
});
test
(
'Service extensions - posttest'
,
()
async
{
// See widget_inspector_test.dart for tests of the ext.flutter.inspector
// service extensions included in this count.
...
...
@@ -539,7 +548,7 @@ void main() {
// If you add a service extension... TEST IT! :-)
// ...then increment this number.
expect
(
binding
.
extensions
.
length
,
2
3
+
widgetInspectorExtensionCount
);
expect
(
binding
.
extensions
.
length
,
2
4
+
widgetInspectorExtensionCount
);
expect
(
console
,
isEmpty
);
debugPrint
=
debugPrintThrottled
;
...
...
packages/flutter_tools/lib/src/commands/run.dart
View file @
c5251cdc
...
...
@@ -33,6 +33,18 @@ abstract class RunCommandBase extends FlutterCommand {
..
addOption
(
'route'
,
help:
'Which route to load when running the app.'
,
)
..
addFlag
(
'save-compilation-trace'
,
hide:
!
verboseHelp
,
negatable:
false
,
help:
'Save runtime compilation trace to a file.
\n
'
'Compilation trace will be saved to compilation.txt when
\'
flutter run
\'
exits. '
'This file contains a list of Dart symbols that were compiled by the runtime JIT '
'compiler up to that point. This file can be used in later --dynamic builds to '
'precompile some code by the offline compiler, thus reducing application startup '
'latency at the cost of larger application package.
\n
'
'This flag is only allowed when running --dynamic --profile (recommended) or '
'--debug mode.
\n
'
)
..
addOption
(
'target-platform'
,
defaultsTo:
'default'
,
allowed:
<
String
>[
'default'
,
'android-arm'
,
'android-arm64'
],
...
...
@@ -318,6 +330,11 @@ class RunCommand extends RunCommandBase {
}
}
if
(
argResults
[
'save-compilation-trace'
]
&&
getBuildMode
()
!=
BuildMode
.
debug
&&
getBuildMode
()
!=
BuildMode
.
dynamicProfile
)
throwToolExit
(
'Error: --save-compilation-trace is only allowed when running '
'--dynamic --profile (recommended) or --debug mode.'
);
final
List
<
FlutterDevice
>
flutterDevices
=
devices
.
map
<
FlutterDevice
>((
Device
device
)
{
return
FlutterDevice
(
device
,
...
...
@@ -343,6 +360,7 @@ class RunCommand extends RunCommandBase {
projectRootPath:
argResults
[
'project-root'
],
packagesFilePath:
globalResults
[
'packages'
],
dillOutputPath:
argResults
[
'output-dill'
],
saveCompilationTrace:
argResults
[
'save-compilation-trace'
],
stayResident:
stayResident
,
ipv6:
ipv6
,
);
...
...
@@ -355,6 +373,7 @@ class RunCommand extends RunCommandBase {
applicationBinary:
applicationBinaryPath
==
null
?
null
:
fs
.
file
(
applicationBinaryPath
),
saveCompilationTrace:
argResults
[
'save-compilation-trace'
],
stayResident:
stayResident
,
ipv6:
ipv6
,
);
...
...
packages/flutter_tools/lib/src/resident_runner.dart
View file @
c5251cdc
...
...
@@ -426,6 +426,7 @@ abstract class ResidentRunner {
this
.
usesTerminalUI
=
true
,
String
projectRootPath
,
String
packagesFilePath
,
this
.
saveCompilationTrace
,
this
.
stayResident
,
this
.
ipv6
,
})
{
...
...
@@ -440,6 +441,7 @@ abstract class ResidentRunner {
final
String
target
;
final
DebuggingOptions
debuggingOptions
;
final
bool
usesTerminalUI
;
final
bool
saveCompilationTrace
;
final
bool
stayResident
;
final
bool
ipv6
;
final
Completer
<
int
>
_finished
=
Completer
<
int
>();
...
...
@@ -487,6 +489,8 @@ abstract class ResidentRunner {
Future
<
void
>
stop
()
async
{
_stopped
=
true
;
if
(
saveCompilationTrace
)
await
_saveCompilationTrace
();
await
stopEchoingDeviceLog
();
await
preStop
();
return
stopApp
();
...
...
@@ -591,6 +595,35 @@ abstract class ResidentRunner {
}
}
Future
<
void
>
_saveCompilationTrace
()
async
{
if
(!
supportsServiceProtocol
)
return
;
for
(
FlutterDevice
device
in
flutterDevices
)
{
for
(
FlutterView
view
in
device
.
views
)
{
final
int
index
=
device
.
views
.
indexOf
(
view
);
printStatus
(
'Saving compilation trace for '
'
${device.device.name}${index == 0 ? '' :'/Isolate$index'}
...'
);
List
<
int
>
buffer
;
try
{
buffer
=
await
view
.
uiIsolate
.
flutterDumpCompilationTrace
();
assert
(
buffer
!=
null
);
}
catch
(
error
)
{
printError
(
'Error communicating with Flutter on the device:
$error
'
);
continue
;
}
final
File
outputFile
=
fs
.
currentDirectory
.
childFile
(
'compilation
${index == 0 ? '' : index}
.txt'
);
outputFile
.
parent
.
createSync
(
recursive:
true
);
outputFile
.
writeAsBytesSync
(
buffer
);
printStatus
(
'Compilation trace written to
${fs.path.relative(outputFile.path)}
.'
);
}
}
}
Future
<
void
>
_debugTogglePlatform
()
async
{
await
refreshViews
();
final
String
from
=
await
flutterDevices
[
0
].
views
[
0
].
uiIsolate
.
flutterPlatformOverride
();
...
...
packages/flutter_tools/lib/src/run_cold.dart
View file @
c5251cdc
...
...
@@ -21,12 +21,14 @@ class ColdRunner extends ResidentRunner {
bool
usesTerminalUI
=
true
,
this
.
traceStartup
=
false
,
this
.
applicationBinary
,
bool
saveCompilationTrace
=
false
,
bool
stayResident
=
true
,
bool
ipv6
=
false
,
})
:
super
(
devices
,
target:
target
,
debuggingOptions:
debuggingOptions
,
usesTerminalUI:
usesTerminalUI
,
saveCompilationTrace:
saveCompilationTrace
,
stayResident:
stayResident
,
ipv6:
ipv6
);
...
...
packages/flutter_tools/lib/src/run_hot.dart
View file @
c5251cdc
...
...
@@ -61,6 +61,7 @@ class HotRunner extends ResidentRunner {
String
projectRootPath
,
String
packagesFilePath
,
this
.
dillOutputPath
,
bool
saveCompilationTrace
=
false
,
bool
stayResident
=
true
,
bool
ipv6
=
false
,
})
:
super
(
devices
,
...
...
@@ -69,6 +70,7 @@ class HotRunner extends ResidentRunner {
usesTerminalUI:
usesTerminalUI
,
projectRootPath:
projectRootPath
,
packagesFilePath:
packagesFilePath
,
saveCompilationTrace:
saveCompilationTrace
,
stayResident:
stayResident
,
ipv6:
ipv6
);
...
...
packages/flutter_tools/lib/src/vmservice.dart
View file @
c5251cdc
...
...
@@ -1312,6 +1312,14 @@ class Isolate extends ServiceObjectOwner {
);
}
Future
<
List
<
int
>>
flutterDumpCompilationTrace
()
async
{
final
Map
<
String
,
dynamic
>
result
=
await
invokeFlutterExtensionRpcRaw
(
'ext.flutter.dumpCompilationTrace'
);
if
(
result
!=
null
&&
result
[
'value'
]
is
List
<
dynamic
>)
return
result
[
'value'
].
cast
<
int
>();
return
null
;
}
// Application control extension methods.
Future
<
Map
<
String
,
dynamic
>>
flutterExit
()
{
return
invokeFlutterExtensionRpcRaw
(
...
...
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