fix an issue with reloading when paused at a breakpoint (#9733)

* fix an issues with reloading when paused at a breakpoint

* update docs
This commit is contained in:
Devon Carew
2017-05-02 16:09:57 -07:00
committed by GitHub
parent 7f9d859e68
commit 7fb6646c96
2 changed files with 29 additions and 4 deletions

View File

@@ -304,8 +304,11 @@ class HotRunner extends ResidentRunner {
}
Future<OperationResult> _restartFromSources() async {
printTrace('Refreshing active FlutterViews before restarting.');
await refreshViews();
if (!_isPaused()) {
printTrace('Refreshing active FlutterViews before restarting.');
await refreshViews();
}
final Stopwatch restartTimer = new Stopwatch();
restartTimer.start();
final bool updatedDevFS = await _updateDevFS();
@@ -401,14 +404,18 @@ class HotRunner extends ResidentRunner {
}
Future<OperationResult> _reloadSources({ bool pause: false }) async {
printTrace('Refreshing active FlutterViews before reloading.');
await refreshViews();
for (FlutterDevice device in flutterDevices) {
for (FlutterView view in device.views) {
if (view.uiIsolate == null)
throw 'Application isolate not found';
}
}
if (!_isPaused()) {
printStatus('Refreshing active FlutterViews before reloading.');
await refreshViews();
}
// The initial launch is from a script snapshot. When we reload from source
// on top of a script snapshot, the first reload will be a worst case reload
// because all of the sources will end up being dirty (library paths will
@@ -563,6 +570,21 @@ class HotRunner extends ResidentRunner {
);
}
bool _isPaused() {
for (FlutterDevice device in flutterDevices) {
for (FlutterView view in device.views) {
if (view.uiIsolate != null) {
final ServiceEvent pauseEvent = view.uiIsolate.pauseEvent;
if (pauseEvent != null && pauseEvent.isPauseEvent) {
return true;
}
}
}
}
return false;
}
@override
void printHelp({ @required bool details }) {
const String fire = '🔥';

View File

@@ -844,6 +844,9 @@ class Isolate extends ServiceObjectOwner {
Isolate get isolate => this;
DateTime startTime;
/// The last pause event delivered to the isolate. If the isolate is running,
/// this will be a resume event.
ServiceEvent pauseEvent;
final Map<String, ServiceObject> _cache = <String, ServiceObject>{};