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
4ed79454
Commit
4ed79454
authored
Feb 11, 2016
by
Devon Carew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wait for flutter start to return until the obs. port is available
parent
abce29f1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
0 deletions
+39
-0
start.dart
packages/flutter_tools/lib/src/commands/start.dart
+35
-0
device.dart
packages/flutter_tools/lib/src/device.dart
+2
-0
device_ios.dart
packages/flutter_tools/lib/src/ios/device_ios.dart
+2
-0
No files found.
packages/flutter_tools/lib/src/commands/start.dart
View file @
4ed79454
...
...
@@ -190,6 +190,13 @@ Future<int> startApp(
printError
(
'Error starting application on
${device.name}
.'
);
}
else
{
startedSomething
=
true
;
// If the user specified --start-paused (and the device supports it) then
// wait for the observatory port to become available before returning from
// `startApp()`.
if
(
startPaused
&&
device
.
supportsStartPaused
)
{
await
_delayUntilObservatoryAvailable
(
'localhost'
,
debugPort
);
}
}
}
...
...
@@ -204,6 +211,34 @@ Future<int> startApp(
return
startedSomething
?
0
:
2
;
}
/// Delay until the Observatory / service protocol is available.
///
/// This does not fail if we're unable to connect, and times out after the given
/// [timeout].
Future
_delayUntilObservatoryAvailable
(
String
host
,
int
port
,
{
Duration
timeout:
const
Duration
(
seconds:
10
)
})
async
{
Stopwatch
stopwatch
=
new
Stopwatch
()..
start
();
final
String
url
=
'ws://
$host
:
$port
/ws'
;
printTrace
(
'Looking for the observatory at
$url
.'
);
while
(
stopwatch
.
elapsed
<=
timeout
)
{
try
{
WebSocket
ws
=
await
WebSocket
.
connect
(
url
);
printTrace
(
'Connected to the observatory port (
${stopwatch.elapsedMilliseconds}
ms).'
);
ws
.
close
().
catchError
((
error
)
=>
null
);
return
;
}
catch
(
error
)
{
await
new
Future
.
delayed
(
new
Duration
(
milliseconds:
250
));
}
}
printTrace
(
'Unable to connect to the observatory.'
);
}
/// Return a relative path if [fullPath] is contained by the cwd, else return an
/// absolute path.
String
_getDisplayPath
(
String
fullPath
)
{
...
...
packages/flutter_tools/lib/src/device.dart
View file @
4ed79454
...
...
@@ -98,6 +98,8 @@ abstract class Device {
String
get
name
;
bool
get
supportsStartPaused
=>
true
;
/// Install an app package on the current device
bool
installApp
(
ApplicationPackage
app
);
...
...
packages/flutter_tools/lib/src/ios/device_ios.dart
View file @
4ed79454
...
...
@@ -82,6 +82,8 @@ class IOSDevice extends Device {
final
String
name
;
bool
get
supportsStartPaused
=>
false
;
static
List
<
IOSDevice
>
getAttachedDevices
([
IOSDevice
mockIOS
])
{
List
<
IOSDevice
>
devices
=
[];
for
(
String
id
in
_getAttachedDeviceIDs
(
mockIOS
))
{
...
...
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