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
0a79ffe7
Commit
0a79ffe7
authored
Aug 05, 2016
by
John McCutchan
Committed by
GitHub
Aug 05, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix hot restart so that it works with iOS simulators (#5272)
parent
2f23137c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
30 deletions
+56
-30
hot.dart
packages/flutter_tools/lib/src/hot.dart
+56
-30
No files found.
packages/flutter_tools/lib/src/hot.dart
View file @
0a79ffe7
...
...
@@ -38,10 +38,13 @@ class HotRunner extends ResidentRunner {
})
:
super
(
device
,
target:
target
,
debuggingOptions:
debuggingOptions
,
usesTerminalUI:
usesTerminalUI
);
usesTerminalUI:
usesTerminalUI
)
{
_projectRootPath
=
Directory
.
current
.
path
;
}
ApplicationPackage
_package
;
String
_mainPath
;
String
_projectRootPath
;
final
AssetBundle
bundle
=
new
AssetBundle
();
/// Start the app and keep the process running during its lifetime.
...
...
@@ -202,13 +205,12 @@ class HotRunner extends ResidentRunner {
}
DevFS
_devFS
;
String
_devFSProjectRootPath
;
Future
<
bool
>
_updateDevFS
({
DevFSProgressReporter
progressReporter
})
async
{
if
(
_devFS
==
null
)
{
Directory
directory
=
Directory
.
current
;
_devFS
ProjectRootPath
=
directory
.
path
;
String
fsName
=
path
.
basename
(
directory
.
path
);
_devFS
=
new
DevFS
(
serviceProtocol
,
fsName
,
directory
);
String
fsName
=
path
.
basename
(
_projectRootPath
)
;
_devFS
=
new
DevFS
(
serviceProtocol
,
fsName
,
new
Directory
(
_projectRootPath
)
);
try
{
await
_devFS
.
create
();
...
...
@@ -242,44 +244,68 @@ class HotRunner extends ResidentRunner {
_devFS
=
null
;
}
Future
<
Null
>
_launchFromDevFS
(
ApplicationPackage
package
,
String
mainScript
)
async
{
String
entryPath
=
path
.
relative
(
mainScript
,
from:
_devFSProjectRootPath
);
String
deviceEntryPath
=
_devFS
.
baseUri
.
resolve
(
entryPath
).
toFilePath
();
String
devicePackagesPath
=
_devFS
.
baseUri
.
resolve
(
'.packages'
).
toFilePath
();
String
deviceAssetsDirectoryPath
=
_devFS
.
baseUri
.
resolve
(
'build/flx'
).
toFilePath
();
Future
<
Null
>
_launchInView
(
String
entryPath
,
String
packagesPath
,
String
assetsDirectoryPath
)
async
{
String
viewId
=
await
serviceProtocol
.
getFirstViewId
();
// When this completer completes the isolate is running.
// TODO(johnmccutchan): Have the framework send an event after the first
// frame is rendered and use that instead of 'runnable'.
Completer
<
Null
>
completer
=
new
Completer
<
Null
>();
StreamSubscription
<
Event
>
subscription
=
serviceProtocol
.
onIsolateEvent
.
listen
((
Event
event
)
{
if
(
event
.
kind
==
'IsolateStart'
)
{
printTrace
(
'Isolate is spawned.'
);
}
else
if
(
event
.
kind
==
'IsolateRunnable'
)
{
printTrace
(
'Isolate is runnable.'
);
completer
.
complete
(
null
);
}
serviceProtocol
.
onIsolateEvent
.
listen
((
Event
event
)
{
if
(
event
.
kind
==
'IsolateStart'
)
{
printTrace
(
'Isolate is spawned.'
);
}
else
if
(
event
.
kind
==
'IsolateRunnable'
)
{
printTrace
(
'Isolate is runnable.'
);
completer
.
complete
(
null
);
}
});
await
serviceProtocol
.
runInView
(
viewId
,
deviceE
ntryPath
,
deviceP
ackagesPath
,
deviceA
ssetsDirectoryPath
);
e
ntryPath
,
p
ackagesPath
,
a
ssetsDirectoryPath
);
await
completer
.
future
;
await
subscription
.
cancel
();
}
Future
<
Null
>
_launchFromDevFS
(
ApplicationPackage
package
,
String
mainScript
)
async
{
String
entryPath
=
path
.
relative
(
mainScript
,
from:
_projectRootPath
);
String
deviceEntryPath
=
_devFS
.
baseUri
.
resolve
(
entryPath
).
toFilePath
();
String
devicePackagesPath
=
_devFS
.
baseUri
.
resolve
(
'.packages'
).
toFilePath
();
String
deviceAssetsDirectoryPath
=
_devFS
.
baseUri
.
resolve
(
'build/flx'
).
toFilePath
();
await
_launchInView
(
deviceEntryPath
,
devicePackagesPath
,
deviceAssetsDirectoryPath
);
}
Future
<
Null
>
_launchFromDisk
(
ApplicationPackage
package
,
String
mainScript
)
async
{
Uri
baseUri
=
new
Uri
.
directory
(
_projectRootPath
);
String
entryPath
=
path
.
relative
(
mainScript
,
from:
_projectRootPath
);
String
diskEntryPath
=
baseUri
.
resolve
(
entryPath
).
toFilePath
();
String
diskPackagesPath
=
baseUri
.
resolve
(
'.packages'
).
toFilePath
();
String
diskAssetsDirectoryPath
=
baseUri
.
resolve
(
'build/flx'
).
toFilePath
();
await
_launchInView
(
diskEntryPath
,
diskPackagesPath
,
diskAssetsDirectoryPath
);
}
Future
<
Null
>
_restartFromSources
()
async
{
if
(
_devFS
!=
null
)
if
(
_devFS
==
null
)
{
Status
restartStatus
=
logger
.
startProgress
(
'Restarting application...'
);
await
_launchFromDisk
(
_package
,
_mainPath
);
restartStatus
.
stop
(
showElapsedTime:
true
);
}
else
{
await
_updateDevFS
();
Status
restartStatus
=
logger
.
startProgress
(
'Restarting application...'
);
await
_launchFromDevFS
(
_package
,
_mainPath
);
restartStatus
.
stop
(
showElapsedTime:
true
);
Status
restartStatus
=
logger
.
startProgress
(
'Restarting application...'
);
await
_launchFromDevFS
(
_package
,
_mainPath
);
restartStatus
.
stop
(
showElapsedTime:
true
);
}
}
/// Returns [true] if the reload was successful.
...
...
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