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
af42e7d7
Unverified
Commit
af42e7d7
authored
Jun 28, 2021
by
Lau Ching Jun
Committed by
GitHub
Jun 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only set assets directory after assets are uploaded onto devfs. (#85418)
parent
b0462184
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
104 additions
and
36 deletions
+104
-36
devfs.dart
packages/flutter_tools/lib/src/devfs.dart
+3
-0
devfs_web.dart
packages/flutter_tools/lib/src/isolated/devfs_web.dart
+4
-0
run_hot.dart
packages/flutter_tools/lib/src/run_hot.dart
+20
-10
resident_runner_test.dart
...lutter_tools/test/general.shard/resident_runner_test.dart
+77
-26
No files found.
packages/flutter_tools/lib/src/devfs.dart
View file @
af42e7d7
...
...
@@ -480,6 +480,9 @@ class DevFS {
final
Directory
rootDirectory
;
final
Set
<
String
>
assetPathsToEvict
=
<
String
>{};
// A flag to indicate whether we have called `setAssetDirectory` on the target device.
bool
hasSetAssetDirectory
=
false
;
List
<
Uri
>
sources
=
<
Uri
>[];
DateTime
lastCompiled
;
DateTime
_previousCompiled
;
...
...
packages/flutter_tools/lib/src/isolated/devfs_web.dart
View file @
af42e7d7
...
...
@@ -660,6 +660,10 @@ class WebDevFS implements DevFS {
Dwds
get
dwds
=>
webAssetServer
.
dwds
;
// A flag to indicate whether we have called `setAssetDirectory` on the target device.
@override
bool
hasSetAssetDirectory
=
false
;
Future
<
DebugConnection
>
_cachedExtensionFuture
;
StreamSubscription
<
void
>
_connectedApps
;
...
...
packages/flutter_tools/lib/src/run_hot.dart
View file @
af42e7d7
...
...
@@ -279,14 +279,6 @@ class HotRunner extends ResidentRunner {
device
.
generator
.
accept
();
}
final
List
<
FlutterView
>
views
=
await
device
.
vmService
.
getFlutterViews
();
final
Uri
deviceAssetsDirectoryUri
=
device
.
devFS
.
baseUri
.
resolveUri
(
globals
.
fs
.
path
.
toUri
(
getAssetBuildDirectory
()));
await
Future
.
wait
<
void
>(
views
.
map
<
Future
<
void
>>(
(
FlutterView
view
)
=>
device
.
vmService
.
setAssetDirectory
(
assetsDirectory:
deviceAssetsDirectoryUri
,
uiIsolateId:
view
.
uiIsolate
.
id
,
viewId:
view
.
id
,
)
));
for
(
final
FlutterView
view
in
views
)
{
globals
.
printTrace
(
'Connected to
$view
.'
);
}
...
...
@@ -896,7 +888,7 @@ class HotRunner extends ResidentRunner {
}
reloadVMTimer
.
stop
();
await
_
evictDirtyAssets
();
await
evictDirtyAssets
();
final
Stopwatch
reassembleTimer
=
_stopwatchFactory
.
createStopwatch
(
'reloadSources:reassemble'
)..
start
();
...
...
@@ -997,13 +989,31 @@ class HotRunner extends ResidentRunner {
printDebuggerList
();
}
Future
<
void
>
_evictDirtyAssets
()
async
{
@visibleForTesting
Future
<
void
>
evictDirtyAssets
()
async
{
final
List
<
Future
<
Map
<
String
,
dynamic
>>>
futures
=
<
Future
<
Map
<
String
,
dynamic
>>>[];
for
(
final
FlutterDevice
device
in
flutterDevices
)
{
if
(
device
.
devFS
.
assetPathsToEvict
.
isEmpty
)
{
continue
;
}
final
List
<
FlutterView
>
views
=
await
device
.
vmService
.
getFlutterViews
();
// If this is the first time we update the assets, make sure to call the setAssetDirectory
if
(!
device
.
devFS
.
hasSetAssetDirectory
)
{
final
Uri
deviceAssetsDirectoryUri
=
device
.
devFS
.
baseUri
.
resolveUri
(
globals
.
fs
.
path
.
toUri
(
getAssetBuildDirectory
()));
await
Future
.
wait
<
void
>(
views
.
map
<
Future
<
void
>>(
(
FlutterView
view
)
=>
device
.
vmService
.
setAssetDirectory
(
assetsDirectory:
deviceAssetsDirectoryUri
,
uiIsolateId:
view
.
uiIsolate
.
id
,
viewId:
view
.
id
,
)
));
for
(
final
FlutterView
view
in
views
)
{
globals
.
printTrace
(
'Set asset directory in
$view
.'
);
}
device
.
devFS
.
hasSetAssetDirectory
=
true
;
}
if
(
views
.
first
.
uiIsolate
==
null
)
{
globals
.
printError
(
'Application isolate not found for
$device
'
);
continue
;
...
...
packages/flutter_tools/test/general.shard/resident_runner_test.dart
View file @
af42e7d7
...
...
@@ -139,6 +139,14 @@ const FakeVmServiceRequest setAssetBundlePath = FakeVmServiceRequest(
}
);
const
FakeVmServiceRequest
evict
=
FakeVmServiceRequest
(
method:
'ext.flutter.evict'
,
args:
<
String
,
Object
>{
'value'
:
'asset'
,
'isolateId'
:
'1'
,
}
);
final
Uri
testUri
=
Uri
.
parse
(
'foo://bar'
);
void
main
(
)
{
...
...
@@ -179,7 +187,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
]);
final
Completer
<
DebugConnectionInfo
>
futureConnectionInfo
=
Completer
<
DebugConnectionInfo
>.
sync
();
final
Completer
<
void
>
futureAppStart
=
Completer
<
void
>.
sync
();
...
...
@@ -203,7 +210,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
]);
final
FakeResidentCompiler
residentCompiler
=
FakeResidentCompiler
()
..
nextOutput
=
const
CompilerOutput
(
'foo'
,
0
,<
Uri
>[]);
...
...
@@ -295,7 +301,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
]);
final
FakeResidentCompiler
residentCompiler
=
FakeResidentCompiler
()
..
nextOutput
=
const
CompilerOutput
(
'foo'
,
0
,<
Uri
>[]);
...
...
@@ -320,7 +325,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
listViews
,
FakeVmServiceRequest
(
method:
'getIsolate'
,
...
...
@@ -389,7 +393,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
listViews
,
]);
final
Completer
<
DebugConnectionInfo
>
futureConnectionInfo
=
Completer
<
DebugConnectionInfo
>.
sync
();
...
...
@@ -422,7 +425,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
]);
final
Completer
<
DebugConnectionInfo
>
futureConnectionInfo
=
Completer
<
DebugConnectionInfo
>.
sync
();
final
Completer
<
void
>
futureAppStart
=
Completer
<
void
>.
sync
();
...
...
@@ -444,7 +446,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
listViews
,
]);
final
Completer
<
DebugConnectionInfo
>
futureConnectionInfo
=
Completer
<
DebugConnectionInfo
>.
sync
();
...
...
@@ -479,7 +480,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
listViews
,
]);
residentRunner
=
HotRunner
(
...
...
@@ -526,7 +526,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
listViews
,
FakeVmServiceRequest
(
method:
'getIsolate'
,
...
...
@@ -571,7 +570,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
listViews
,
FakeVmServiceRequest
(
method:
'getVM'
,
...
...
@@ -632,7 +630,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
listViews
,
FakeVmServiceRequest
(
method:
'getVM'
,
...
...
@@ -697,7 +694,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
listViews
,
FakeVmServiceRequest
(
method:
'getVM'
,
...
...
@@ -765,7 +761,6 @@ void main() {
jsonResponse:
fakeVM
.
toJson
(),
),
listViews
,
setAssetBundlePath
,
listViews
,
FakeVmServiceRequest
(
method:
'getVM'
,
...
...
@@ -853,7 +848,6 @@ void main() {
listViews
,
listViews
,
listViews
,
setAssetBundlePath
,
FakeVmServiceRequest
(
method:
'getIsolate'
,
args:
<
String
,
Object
>{
...
...
@@ -914,7 +908,6 @@ void main() {
listViews
,
listViews
,
listViews
,
setAssetBundlePath
,
FakeVmServiceRequest
(
method:
'getIsolate'
,
args:
<
String
,
Object
>{
...
...
@@ -981,7 +974,6 @@ void main() {
listViews
,
listViews
,
listViews
,
setAssetBundlePath
,
FakeVmServiceRequest
(
method:
'getIsolate'
,
args:
<
String
,
Object
>{
...
...
@@ -1103,7 +1095,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
]);
final
Completer
<
DebugConnectionInfo
>
futureConnectionInfo
=
Completer
<
DebugConnectionInfo
>.
sync
();
final
Completer
<
void
>
futureAppStart
=
Completer
<
void
>.
sync
();
...
...
@@ -1421,7 +1412,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
]);
residentRunner
=
ColdRunner
(
<
FlutterDevice
>[
...
...
@@ -1465,7 +1455,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
],
wsAddress:
testUri
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
residentRunner
=
HotRunner
(
...
...
@@ -1488,7 +1477,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
],
wsAddress:
testUri
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
residentRunner
=
HotRunner
(
...
...
@@ -1511,7 +1499,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
],
wsAddress:
testUri
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
residentRunner
=
HotRunner
(
...
...
@@ -1542,7 +1529,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
],
wsAddress:
testUri
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
residentRunner
=
HotRunner
(
...
...
@@ -1573,7 +1559,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
],
wsAddress:
testUri
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
residentRunner
=
HotRunner
(
...
...
@@ -1597,7 +1582,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
],
wsAddress:
testUri
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
residentRunner
=
HotRunner
(
...
...
@@ -1625,7 +1609,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
],
wsAddress:
testUri
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
residentRunner
=
HotRunner
(
...
...
@@ -1646,7 +1629,6 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
]);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
residentRunner
=
HotRunner
(
...
...
@@ -1925,6 +1907,72 @@ void main() {
expect
((
residentRunner
.
residentDevtoolsHandler
as
NoOpDevtoolsHandler
).
wasShutdown
,
true
);
}));
testUsingContext
(
'HotRunner sets asset directory when first evict assets'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
setAssetBundlePath
,
evict
,
]);
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
flutterDevice
,
],
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
target:
'main.dart'
,
devtoolsHandler:
createNoOpHandler
,
);
(
flutterDevice
.
devFS
as
FakeDevFS
).
assetPathsToEvict
=
<
String
>{
'asset'
};
expect
(
flutterDevice
.
devFS
.
hasSetAssetDirectory
,
false
);
await
(
residentRunner
as
HotRunner
).
evictDirtyAssets
();
expect
(
flutterDevice
.
devFS
.
hasSetAssetDirectory
,
true
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
testUsingContext
(
'HotRunner does not sets asset directory when no assets to evict'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
]);
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
flutterDevice
,
],
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
target:
'main.dart'
,
devtoolsHandler:
createNoOpHandler
,
);
expect
(
flutterDevice
.
devFS
.
hasSetAssetDirectory
,
false
);
await
(
residentRunner
as
HotRunner
).
evictDirtyAssets
();
expect
(
flutterDevice
.
devFS
.
hasSetAssetDirectory
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
testUsingContext
(
'HotRunner does not set asset directory if it has been set before'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
evict
,
]);
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
flutterDevice
,
],
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
target:
'main.dart'
,
devtoolsHandler:
createNoOpHandler
,
);
(
flutterDevice
.
devFS
as
FakeDevFS
).
assetPathsToEvict
=
<
String
>{
'asset'
};
flutterDevice
.
devFS
.
hasSetAssetDirectory
=
true
;
await
(
residentRunner
as
HotRunner
).
evictDirtyAssets
();
expect
(
flutterDevice
.
devFS
.
hasSetAssetDirectory
,
true
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
}
class
FakeDartDevelopmentServiceException
implements
dds
.
DartDevelopmentServiceException
{
...
...
@@ -2231,6 +2279,9 @@ class FakeDevFS extends Fake implements DevFS {
UpdateFSReport
nextUpdateReport
=
UpdateFSReport
(
success:
true
);
@override
bool
hasSetAssetDirectory
=
false
;
@override
Future
<
Uri
>
create
()
async
{
return
Uri
();
...
...
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