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
50dfd137
Unverified
Commit
50dfd137
authored
Jan 06, 2021
by
Jonah Williams
Committed by
GitHub
Jan 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] prevent hot reload/restart if device has not finished devFS initialization (#73420)
parent
a8247e78
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
12 deletions
+37
-12
run_hot.dart
packages/flutter_tools/lib/src/run_hot.dart
+5
-11
hot_test.dart
packages/flutter_tools/test/general.shard/hot_test.dart
+1
-1
resident_runner_test.dart
...lutter_tools/test/general.shard/resident_runner_test.dart
+31
-0
No files found.
packages/flutter_tools/lib/src/run_hot.dart
View file @
50dfd137
...
...
@@ -8,7 +8,6 @@ import 'package:vm_service/vm_service.dart' as vm_service;
import
'package:meta/meta.dart'
;
import
'package:pool/pool.dart'
;
import
'base/async_guard.dart'
;
import
'base/context.dart'
;
import
'base/file_system.dart'
;
import
'base/logger.dart'
;
...
...
@@ -105,6 +104,7 @@ class HotRunner extends ResidentRunner {
/// reload process do not have this issue.
bool
_swap
=
false
;
/// Whether the resident runner has correctly attached to the running application.
bool
_didAttach
=
false
;
final
Map
<
String
,
List
<
int
>>
benchmarkData
=
<
String
,
List
<
int
>>{};
...
...
@@ -121,7 +121,6 @@ class HotRunner extends ResidentRunner {
bool
force
=
false
,
bool
pause
=
false
,
})
async
{
// TODO(cbernaschina): check that isolateId is the id of the UI isolate.
final
OperationResult
result
=
await
restart
(
pause:
pause
);
if
(!
result
.
isOk
)
{
throw
vm_service
.
RPCError
(
...
...
@@ -469,8 +468,6 @@ class HotRunner extends ResidentRunner {
String
reason
,
})
async
{
final
Stopwatch
restartTimer
=
Stopwatch
()..
start
();
// TODO(aam): Add generator reset logic once we switch to using incremental
// compiler for full application recompilation on restart.
final
UpdateFSReport
updatedDevFS
=
await
_updateDevFS
(
fullRestart:
true
);
if
(!
updatedDevFS
.
success
)
{
for
(
final
FlutterDevice
device
in
flutterDevices
)
{
...
...
@@ -592,6 +589,9 @@ class HotRunner extends ResidentRunner {
bool
silent
=
false
,
bool
pause
=
false
,
})
async
{
if
(
flutterDevices
.
any
((
FlutterDevice
device
)
=>
device
.
devFS
==
null
))
{
return
OperationResult
(
1
,
'Device initialization has not completed.'
);
}
String
targetPlatform
;
String
sdkName
;
bool
emulator
;
...
...
@@ -666,13 +666,7 @@ class HotRunner extends ResidentRunner {
if
(!(
await
hotRunnerConfig
.
setupHotRestart
()))
{
return
OperationResult
(
1
,
'setupHotRestart failed'
);
}
// The current implementation of the vmservice and JSON rpc may throw
// unhandled exceptions into the zone that cannot be caught with a regular
// try catch. The usage is [asyncGuard] is required to normalize the error
// handling, at least until we can refactor the underlying code.
result
=
await
asyncGuard
(()
=>
_restartFromSources
(
reason:
reason
,
));
result
=
await
_restartFromSources
(
reason:
reason
,);
if
(!
result
.
isOk
)
{
restartEvent
=
'restart-failed'
;
}
...
...
packages/flutter_tools/test/general.shard/hot_test.dart
View file @
50dfd137
...
...
@@ -343,7 +343,7 @@ void main() {
when
(
mockDevice
.
supportsHotRestart
).
thenReturn
(
true
);
when
(
mockDevice
.
targetPlatform
).
thenAnswer
((
Invocation
_
)
async
=>
TargetPlatform
.
tester
);
final
List
<
FlutterDevice
>
devices
=
<
FlutterDevice
>[
FlutterDevice
(
mockDevice
,
generator:
residentCompiler
,
buildInfo:
BuildInfo
.
debug
),
FlutterDevice
(
mockDevice
,
generator:
residentCompiler
,
buildInfo:
BuildInfo
.
debug
)
..
devFS
=
MockDevFs
()
,
];
final
OperationResult
result
=
await
HotRunner
(
devices
,
...
...
packages/flutter_tools/test/general.shard/resident_runner_test.dart
View file @
50dfd137
...
...
@@ -541,6 +541,37 @@ void main() {
Usage:
()
=>
MockUsage
(),
}));
testUsingContext
(
'ResidentRunner fails its operation if the device initialization is not complete'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
]);
when
(
mockDevice
.
sdkNameAndVersion
).
thenAnswer
((
Invocation
invocation
)
async
{
return
'Example'
;
});
when
(
mockDevice
.
targetPlatform
).
thenAnswer
((
Invocation
invocation
)
async
{
return
TargetPlatform
.
android_arm
;
});
when
(
mockDevice
.
isLocalEmulator
).
thenAnswer
((
Invocation
invocation
)
async
{
return
false
;
});
final
Completer
<
DebugConnectionInfo
>
onConnectionInfo
=
Completer
<
DebugConnectionInfo
>.
sync
();
final
Completer
<
void
>
onAppStart
=
Completer
<
void
>.
sync
();
unawaited
(
residentRunner
.
attach
(
appStartedCompleter:
onAppStart
,
connectionInfoCompleter:
onConnectionInfo
,
));
await
onAppStart
.
future
;
when
(
mockFlutterDevice
.
devFS
).
thenReturn
(
null
);
final
OperationResult
result
=
await
residentRunner
.
restart
(
fullRestart:
false
);
expect
(
result
.
fatal
,
false
);
expect
(
result
.
code
,
1
);
expect
(
result
.
message
,
contains
(
'Device initialization has not completed.'
));
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
testUsingContext
(
'ResidentRunner can handle an reload-barred exception from hot reload'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
...
...
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