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
598f2ab0
Unverified
Commit
598f2ab0
authored
Nov 27, 2019
by
Jonah Williams
Committed by
GitHub
Nov 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanups to resident runner and flutter device classes (#45673)
parent
b39949ff
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
69 additions
and
99 deletions
+69
-99
device.dart
packages/flutter_tools/lib/src/device.dart
+2
-2
devices.dart
packages/flutter_tools/lib/src/ios/devices.dart
+15
-18
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+22
-38
run_cold.dart
packages/flutter_tools/lib/src/run_cold.dart
+9
-10
run_hot.dart
packages/flutter_tools/lib/src/run_hot.dart
+19
-29
resident_runner_test.dart
...lutter_tools/test/general.shard/resident_runner_test.dart
+2
-2
No files found.
packages/flutter_tools/lib/src/device.dart
View file @
598f2ab0
...
...
@@ -645,7 +645,7 @@ abstract class DeviceLogReader {
/// Some logs can be obtained from a VM service stream.
/// Set this after the VM services are connected.
List
<
VMService
>
connectedVMServices
;
VMService
connectedVMService
;
@override
String
toString
()
=>
name
;
...
...
@@ -675,7 +675,7 @@ class NoOpDeviceLogReader implements DeviceLogReader {
int
appPid
;
@override
List
<
VMService
>
connectedVMServices
;
VMService
connectedVMService
;
@override
Stream
<
String
>
get
logLines
=>
const
Stream
<
String
>.
empty
();
...
...
packages/flutter_tools/lib/src/ios/devices.dart
View file @
598f2ab0
...
...
@@ -578,33 +578,30 @@ class IOSDeviceLogReader extends DeviceLogReader {
String
get
name
=>
device
.
name
;
@override
List
<
VMService
>
get
connectedVMServices
=>
_connectedVMServices
;
List
<
VMService
>
_connectedVMServices
;
VMService
get
connectedVMService
=>
_connectedVMService
;
VMService
_connectedVMService
;
@override
set
connectedVMService
s
(
List
<
VMService
>
connectedVMServices
)
{
_listenToUnifiedLoggingEvents
(
connectedV
MServices
);
_connectedVMService
s
=
connectedVMServices
;
set
connectedVMService
(
VMService
connectedVmService
)
{
_listenToUnifiedLoggingEvents
(
connectedV
mService
);
_connectedVMService
=
connectedVmService
;
}
static
const
int
_minimumUniversalLoggingSdkVersion
=
13
;
Future
<
void
>
_listenToUnifiedLoggingEvents
(
List
<
VMService
>
vmServices
)
async
{
Future
<
void
>
_listenToUnifiedLoggingEvents
(
VMService
connectedVmService
)
async
{
if
(
device
.
majorSdkVersion
<
_minimumUniversalLoggingSdkVersion
)
{
return
;
}
for
(
VMService
vmService
in
vmServices
)
{
// The VM service will not publish logging events unless the debug stream is being listened to.
// onDebugEvent listens to this stream as a side effect.
unawaited
(
vmService
.
onDebugEvent
);
_loggingSubscriptions
.
add
((
await
vmService
.
onStdoutEvent
).
listen
((
ServiceEvent
event
)
{
final
String
logMessage
=
event
.
message
;
if
(
logMessage
.
isNotEmpty
)
{
_linesController
.
add
(
logMessage
);
}
}));
}
_connectedVMServices
=
connectedVMServices
;
// The VM service will not publish logging events unless the debug stream is being listened to.
// onDebugEvent listens to this stream as a side effect.
unawaited
(
connectedVmService
.
onDebugEvent
);
_loggingSubscriptions
.
add
((
await
connectedVmService
.
onStdoutEvent
).
listen
((
ServiceEvent
event
)
{
final
String
logMessage
=
event
.
message
;
if
(
logMessage
.
isNotEmpty
)
{
_linesController
.
add
(
logMessage
);
}
}));
}
void
_listenToSysLog
()
{
...
...
packages/flutter_tools/lib/src/resident_runner.dart
View file @
598f2ab0
...
...
@@ -134,7 +134,7 @@ class FlutterDevice {
final
Device
device
;
final
ResidentCompiler
generator
;
Stream
<
Uri
>
observatoryUris
;
List
<
VMService
>
vmServices
;
VMService
vmService
;
DevFS
devFS
;
ApplicationPackage
package
;
List
<
String
>
fileSystemRoots
;
...
...
@@ -191,8 +191,8 @@ class FlutterDevice {
}
printTrace
(
'Successfully connected to service protocol:
$observatoryUri
'
);
vmService
s
=
<
VMService
>[
service
]
;
device
.
getLogReader
(
app:
package
).
connectedVMService
s
=
vmServices
;
vmService
=
service
;
device
.
getLogReader
(
app:
package
).
connectedVMService
=
vmService
;
completer
.
complete
();
await
subscription
.
cancel
();
},
onError:
(
dynamic
error
)
{
...
...
@@ -208,37 +208,23 @@ class FlutterDevice {
}
Future
<
void
>
refreshViews
()
async
{
if
(
vmService
s
==
null
||
vmServices
.
isEmpty
)
{
return
Future
<
void
>.
value
(
null
)
;
if
(
vmService
==
null
)
{
return
;
}
final
List
<
Future
<
void
>>
futures
=
<
Future
<
void
>>[
for
(
VMService
service
in
vmServices
)
service
.
vm
.
refreshViews
(
waitForViews:
true
),
];
await
Future
.
wait
(
futures
);
await
vmService
.
vm
.
refreshViews
(
waitForViews:
true
);
}
List
<
FlutterView
>
get
views
{
if
(
vmService
s
==
null
)
{
if
(
vmService
==
null
||
vmService
.
isClosed
)
{
return
<
FlutterView
>[];
}
return
vmServices
.
where
((
VMService
service
)
=>
!
service
.
isClosed
)
.
expand
<
FlutterView
>(
(
VMService
service
)
{
return
viewFilter
!=
null
?
service
.
vm
.
allViewsWithName
(
viewFilter
)
:
service
.
vm
.
views
;
},
)
.
toList
();
return
(
viewFilter
!=
null
?
vmService
.
vm
.
allViewsWithName
(
viewFilter
)
:
vmService
.
vm
.
views
).
toList
();
}
Future
<
void
>
getVMs
()
async
{
for
(
VMService
service
in
vmServices
)
{
await
service
.
getVM
();
}
}
Future
<
void
>
getVMs
()
=>
vmService
.
getVM
();
Future
<
void
>
exitApps
()
async
{
if
(!
device
.
supportsFlutterExit
)
{
...
...
@@ -249,7 +235,6 @@ class FlutterDevice {
if
(
flutterViews
==
null
||
flutterViews
.
isEmpty
)
{
return
;
}
final
List
<
Future
<
void
>>
futures
=
<
Future
<
void
>>[];
// If any of the flutter views are paused, we might not be able to
// cleanly exit since the service extension may not have been registered.
if
(
flutterViews
.
any
((
FlutterView
view
)
{
...
...
@@ -262,6 +247,7 @@ class FlutterDevice {
await
device
.
stopApp
(
package
);
return
;
}
final
List
<
Future
<
void
>>
futures
=
<
Future
<
void
>>[];
for
(
FlutterView
view
in
flutterViews
)
{
if
(
view
!=
null
&&
view
.
uiIsolate
!=
null
)
{
assert
(!
view
.
uiIsolate
.
pauseEvent
.
isPauseEvent
);
...
...
@@ -281,7 +267,7 @@ class FlutterDevice {
})
{
// One devFS per device. Shared by all running instances.
devFS
=
DevFS
(
vmService
s
[
0
]
,
vmService
,
fsName
,
rootDirectory
,
packagesFilePath:
packagesFilePath
,
...
...
@@ -416,7 +402,7 @@ class FlutterDevice {
}
void
initLogReader
()
{
device
.
getLogReader
(
app:
package
).
appPid
=
vmService
s
.
first
.
vm
.
pid
;
device
.
getLogReader
(
app:
package
).
appPid
=
vmService
.
vm
.
pid
;
}
Future
<
int
>
runHot
({
...
...
@@ -736,7 +722,7 @@ abstract class ResidentRunner {
void
writeVmserviceFile
()
{
if
(
debuggingOptions
.
vmserviceOutFile
!=
null
)
{
try
{
final
String
address
=
flutterDevices
.
first
.
vmService
s
.
first
.
wsAddress
.
toString
();
final
String
address
=
flutterDevices
.
first
.
vmService
.
wsAddress
.
toString
();
final
File
vmserviceOutFile
=
fs
.
file
(
debuggingOptions
.
vmserviceOutFile
);
vmserviceOutFile
.
createSync
(
recursive:
true
);
vmserviceOutFile
.
writeAsStringSync
(
address
);
...
...
@@ -940,15 +926,13 @@ abstract class ResidentRunner {
// Listen for service protocol connection to close.
for
(
FlutterDevice
device
in
flutterDevices
)
{
for
(
VMService
service
in
device
.
vmServices
)
{
// This hooks up callbacks for when the connection stops in the future.
// We don't want to wait for them. We don't handle errors in those callbacks'
// futures either because they just print to logger and is not critical.
unawaited
(
service
.
done
.
then
<
void
>(
_serviceProtocolDone
,
onError:
_serviceProtocolError
,
).
whenComplete
(
_serviceDisconnected
));
}
// This hooks up callbacks for when the connection stops in the future.
// We don't want to wait for them. We don't handle errors in those callbacks'
// futures either because they just print to logger and is not critical.
unawaited
(
device
.
vmService
.
done
.
then
<
void
>(
_serviceProtocolDone
,
onError:
_serviceProtocolError
,
).
whenComplete
(
_serviceDisconnected
));
}
}
...
...
packages/flutter_tools/lib/src/run_cold.dart
View file @
598f2ab0
...
...
@@ -83,15 +83,15 @@ class ColdRunner extends ResidentRunner {
if
(
flutterDevices
.
first
.
observatoryUris
!=
null
)
{
// For now, only support one debugger connection.
connectionInfoCompleter
?.
complete
(
DebugConnectionInfo
(
httpUri:
flutterDevices
.
first
.
vmService
s
.
first
.
httpAddress
,
wsUri:
flutterDevices
.
first
.
vmService
s
.
first
.
wsAddress
,
httpUri:
flutterDevices
.
first
.
vmService
.
httpAddress
,
wsUri:
flutterDevices
.
first
.
vmService
.
wsAddress
,
));
}
printTrace
(
'Application running.'
);
for
(
FlutterDevice
device
in
flutterDevices
)
{
if
(
device
.
vmService
s
==
null
)
{
if
(
device
.
vmService
==
null
)
{
continue
;
}
device
.
initLogReader
();
...
...
@@ -102,10 +102,10 @@ class ColdRunner extends ResidentRunner {
if
(
traceStartup
)
{
// Only trace startup for the first device.
final
FlutterDevice
device
=
flutterDevices
.
first
;
if
(
device
.
vmService
s
!=
null
&&
device
.
vmServices
.
isNotEmpty
)
{
if
(
device
.
vmService
!=
null
)
{
printStatus
(
'Tracing startup on
${device.device.name}
.'
);
await
downloadStartupTrace
(
device
.
vmService
s
.
first
,
device
.
vmService
,
awaitFirstFrame:
awaitFirstFrameWhenTracing
,
);
}
...
...
@@ -183,10 +183,9 @@ class ColdRunner extends ResidentRunner {
bool
haveAnything
=
false
;
for
(
FlutterDevice
device
in
flutterDevices
)
{
final
String
dname
=
device
.
device
.
name
;
if
(
device
.
vmServices
!=
null
)
{
for
(
VMService
vm
in
device
.
vmServices
)
{
printStatus
(
'An Observatory debugger and profiler on
$dname
is available at:
${vm.httpAddress}
'
);
}
if
(
device
.
vmService
!=
null
)
{
printStatus
(
'An Observatory debugger and profiler on
$dname
is '
'available at:
${device.vmService .httpAddress}
'
);
}
}
if
(
supportsServiceProtocol
)
{
...
...
@@ -212,7 +211,7 @@ class ColdRunner extends ResidentRunner {
Future
<
void
>
preExit
()
async
{
for
(
FlutterDevice
device
in
flutterDevices
)
{
// If we're running in release mode, stop the app using the device logic.
if
(
device
.
vmService
s
==
null
||
device
.
vmServices
.
isEmpty
)
{
if
(
device
.
vmService
==
null
)
{
await
device
.
device
.
stopApp
(
device
.
package
);
}
}
...
...
packages/flutter_tools/lib/src/run_hot.dart
View file @
598f2ab0
...
...
@@ -10,7 +10,6 @@ import 'package:meta/meta.dart';
import
'package:pool/pool.dart'
;
import
'base/async_guard.dart'
;
import
'base/common.dart'
;
import
'base/context.dart'
;
import
'base/file_system.dart'
;
import
'base/logger.dart'
;
...
...
@@ -180,8 +179,8 @@ class HotRunner extends ResidentRunner {
// Only handle one debugger connection.
connectionInfoCompleter
.
complete
(
DebugConnectionInfo
(
httpUri:
flutterDevices
.
first
.
vmService
s
.
first
.
httpAddress
,
wsUri:
flutterDevices
.
first
.
vmService
s
.
first
.
wsAddress
,
httpUri:
flutterDevices
.
first
.
vmService
.
httpAddress
,
wsUri:
flutterDevices
.
first
.
vmService
.
wsAddress
,
baseUri:
baseUris
.
first
.
toString
(),
),
);
...
...
@@ -428,23 +427,18 @@ class HotRunner extends ResidentRunner {
continue
;
}
// Reload the isolate.
final
Completer
<
void
>
completer
=
Completer
<
void
>();
futures
.
add
(
completer
.
future
);
unawaited
(
view
.
uiIsolate
.
reload
().
then
(
(
ServiceObject
_
)
{
final
ServiceEvent
pauseEvent
=
view
.
uiIsolate
.
pauseEvent
;
if
((
pauseEvent
!=
null
)
&&
pauseEvent
.
isPauseEvent
)
{
// Resume the isolate so that it can be killed by the embedder.
return
view
.
uiIsolate
.
resume
();
}
return
null
;
},
).
whenComplete
(
()
{
completer
.
complete
(
null
);
},
));
futures
.
add
(
view
.
uiIsolate
.
reload
().
then
((
ServiceObject
_
)
{
final
ServiceEvent
pauseEvent
=
view
.
uiIsolate
.
pauseEvent
;
if
((
pauseEvent
!=
null
)
&&
pauseEvent
.
isPauseEvent
)
{
// Resume the isolate so that it can be killed by the embedder.
return
view
.
uiIsolate
.
resume
();
}
return
null
;
}));
}
}
await
Future
.
wait
(
futures
);
// We are now running from source.
_runningFromSnapshot
=
false
;
await
_launchFromDevFS
(
mainPath
+
'.dill'
);
...
...
@@ -718,12 +712,10 @@ class HotRunner extends ResidentRunner {
// running from snapshot to running from uploaded files.
await
device
.
resetAssetDirectory
();
}
final
Completer
<
DeviceReloadReport
>
completer
=
Completer
<
DeviceReloadReport
>();
allReportsFutures
.
add
(
completer
.
future
);
final
List
<
Future
<
Map
<
String
,
dynamic
>>>
reportFutures
=
device
.
reloadSources
(
entryPath
,
pause:
pause
,
);
unawaite
d
(
Future
.
wait
(
reportFutures
).
then
(
allReportsFutures
.
ad
d
(
Future
.
wait
(
reportFutures
).
then
(
(
List
<
Map
<
String
,
dynamic
>>
reports
)
async
{
// TODO(aam): Investigate why we are validating only first reload report,
// which seems to be current behavior
...
...
@@ -733,7 +725,7 @@ class HotRunner extends ResidentRunner {
await
device
.
updateReloadStatus
(
validateReloadReport
(
firstReport
,
printErrors:
false
),
);
completer
.
complete
(
DeviceReloadReport
(
device
,
reports
)
);
return
DeviceReloadReport
(
device
,
reports
);
},
));
}
...
...
@@ -795,13 +787,12 @@ class HotRunner extends ResidentRunner {
printTrace
(
'Sending reload event to "
${view.uiIsolate.name}
"'
);
futuresViews
.
add
(
view
.
uiIsolate
.
reload
());
}
final
Completer
<
void
>
deviceCompleter
=
Completer
<
void
>();
unawaited
(
Future
.
wait
(
futuresViews
).
whenComplete
(()
{
deviceCompleter
.
complete
(
device
.
refreshViews
());
allDevices
.
add
(
Future
.
wait
(
futuresViews
).
whenComplete
(()
{
return
device
.
refreshViews
();
}));
allDevices
.
add
(
deviceCompleter
.
future
);
}
await
Future
.
wait
(
allDevices
);
// We are now running from source.
_runningFromSnapshot
=
false
;
// Check if any isolates are paused.
...
...
@@ -851,7 +842,7 @@ class HotRunner extends ResidentRunner {
}
}(),
];
final
Future
<
void
>
reassembleFuture
=
Future
.
wait
<
void
>(
futures
)
.
then
<
void
>((
List
<
void
>
values
)
{
})
;
final
Future
<
void
>
reassembleFuture
=
Future
.
wait
<
void
>(
futures
);
await
reassembleFuture
.
timeout
(
const
Duration
(
seconds:
2
),
onTimeout:
()
async
{
...
...
@@ -987,9 +978,8 @@ class HotRunner extends ResidentRunner {
printStatus
(
message
);
for
(
FlutterDevice
device
in
flutterDevices
)
{
final
String
dname
=
device
.
device
.
name
;
for
(
VMService
vm
in
device
.
vmServices
)
{
printStatus
(
'An Observatory debugger and profiler on
$dname
is available at:
${vm.httpAddress}
'
);
}
printStatus
(
'An Observatory debugger and profiler on
$dname
is '
'available at:
${device.vmService.httpAddress}
'
);
}
final
String
quitMessage
=
_didAttach
?
'To detach, press "d"; to quit, press "q".'
...
...
packages/flutter_tools/test/general.shard/resident_runner_test.dart
View file @
598f2ab0
...
...
@@ -104,7 +104,7 @@ void main() {
.
thenAnswer
((
Invocation
invocation
)
async
{
return
testUri
;
});
when
(
mockFlutterDevice
.
vmService
s
).
thenReturn
(<
VMService
>[
mockVMService
]
);
when
(
mockFlutterDevice
.
vmService
).
thenReturn
(
mockVMService
);
when
(
mockFlutterDevice
.
refreshViews
()).
thenAnswer
((
Invocation
invocation
)
async
{
});
when
(
mockFlutterDevice
.
reloadSources
(
any
,
pause:
anyNamed
(
'pause'
))).
thenReturn
(<
Future
<
Map
<
String
,
dynamic
>>>[
Future
<
Map
<
String
,
dynamic
>>.
value
(<
String
,
dynamic
>{
...
...
@@ -631,7 +631,7 @@ void main() {
);
await
flutterDevice
.
connect
();
verify
(
mockLogReader
.
connectedVMService
s
=
<
VMService
>[
mockVMService
]
);
verify
(
mockLogReader
.
connectedVMService
=
mockVMService
);
},
overrides:
<
Type
,
Generator
>{
VMServiceConnector:
()
=>
(
Uri
httpUri
,
{
ReloadSources
reloadSources
,
...
...
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