@@ -473,8 +473,9 @@ class ChromeProxyService implements VmServiceInterface {
473
473
if (! _isIsolateRunning) return ;
474
474
final isolate = inspector.isolate;
475
475
476
+ final debugger = await debuggerFuture;
476
477
for (final breakpoint in isolate.breakpoints? .toList () ?? < Breakpoint > []) {
477
- await ( await debuggerFuture) .removeBreakpoint (breakpoint.id! );
478
+ await debugger .removeBreakpoint (breakpoint.id! );
478
479
}
479
480
}
480
481
@@ -1210,43 +1211,7 @@ class ChromeProxyService implements VmServiceInterface {
1210
1211
returnByValue: true ,
1211
1212
);
1212
1213
1213
- if (pauseIsolatesOnStart) {
1214
- // If `pause_isolates_on_start` is enabled, pause and then the reload
1215
- // should finish later after the client removes breakpoints, reregisters
1216
- // breakpoints, and resumes.
1217
- _finishHotReloadOnResume = () async {
1218
- // Client finished setting breakpoints, called resume, and now the
1219
- // execution has resumed. Finish the hot reload so we start executing
1220
- // the new code instead.
1221
- _logger.info ('Issuing \$ dartHotReloadEndDwds request' );
1222
- await inspector.jsEvaluate (
1223
- '\$ dartHotReloadEndDwds();' ,
1224
- awaitPromise: true ,
1225
- );
1226
- _logger.info ('\$ dartHotReloadEndDwds request complete.' );
1227
- };
1228
-
1229
- // Pause and wait for the pause to occur before managing breakpoints.
1230
- final pausedEvent = _firstStreamEvent (
1231
- 'Debug' ,
1232
- EventKind .kPauseInterrupted,
1233
- );
1234
- await pause (isolateId);
1235
- await pausedEvent;
1236
-
1237
- await _reinitializeForHotReload ();
1238
-
1239
- // This lets the client know that we're ready for breakpoint management
1240
- // and a resume.
1241
- _streamNotify (
1242
- 'Debug' ,
1243
- Event (
1244
- kind: EventKind .kPausePostRequest,
1245
- timestamp: DateTime .now ().millisecondsSinceEpoch,
1246
- isolate: inspector.isolateRef,
1247
- ),
1248
- );
1249
- } else {
1214
+ if (! pauseIsolatesOnStart) {
1250
1215
// Finish hot reload immediately.
1251
1216
_logger.info ('Issuing \$ dartHotReloadEndDwds request' );
1252
1217
await inspector.jsEvaluate (
@@ -1257,7 +1222,40 @@ class ChromeProxyService implements VmServiceInterface {
1257
1222
// TODO(srujzs): Supposedly Dart DevTools uses a kIsolateReload event
1258
1223
// for breakpoints? We should confirm and add tests before sending the
1259
1224
// event.
1225
+ return ;
1260
1226
}
1227
+ // If `pause_isolates_on_start` is enabled, pause and then the reload
1228
+ // should finish later after the client removes breakpoints, reregisters
1229
+ // breakpoints, and resumes.
1230
+ _finishHotReloadOnResume = () async {
1231
+ // Client finished setting breakpoints, called resume, and now the
1232
+ // execution has resumed. Finish the hot reload so we start executing
1233
+ // the new code instead.
1234
+ _logger.info ('Issuing \$ dartHotReloadEndDwds request' );
1235
+ await inspector.jsEvaluate (
1236
+ '\$ dartHotReloadEndDwds();' ,
1237
+ awaitPromise: true ,
1238
+ );
1239
+ _logger.info ('\$ dartHotReloadEndDwds request complete.' );
1240
+ };
1241
+
1242
+ // Pause and wait for the pause to occur before managing breakpoints.
1243
+ final pausedEvent = _firstStreamEvent ('Debug' , EventKind .kPauseInterrupted);
1244
+ await pause (isolateId);
1245
+ await pausedEvent;
1246
+
1247
+ await _reinitializeForHotReload ();
1248
+
1249
+ // This lets the client know that we're ready for breakpoint management
1250
+ // and a resume.
1251
+ _streamNotify (
1252
+ 'Debug' ,
1253
+ Event (
1254
+ kind: EventKind .kPausePostRequest,
1255
+ timestamp: DateTime .now ().millisecondsSinceEpoch,
1256
+ isolate: inspector.isolateRef,
1257
+ ),
1258
+ );
1261
1259
}
1262
1260
1263
1261
/// Performs a WebSocket-based hot reload by sending a request and waiting for a response.
@@ -1319,37 +1317,30 @@ class ChromeProxyService implements VmServiceInterface {
1319
1317
String ? step,
1320
1318
int ? frameIndex,
1321
1319
}) async {
1322
- // If there is a hot restart or hot reload subscriber listening for a resume
1323
- // event after a hot restart or a hot reload, then add the event to the
1324
- // stream and skip processing it.
1320
+ // If there is a subscriber listening for a resume event after hot-restart,
1321
+ // then add the event to the stream and skip processing it.
1325
1322
if (_resumeAfterRestartEventsController.hasListener) {
1326
1323
_resumeAfterRestartEventsController.add (isolateId);
1327
1324
return Success ();
1328
1325
}
1329
- Future <Success > resumeWhenAppHasStarted () {
1330
- return captureElapsedTime (() async {
1326
+
1327
+ if (inspector.appConnection.isStarted) {
1328
+ await captureElapsedTime (() async {
1331
1329
await isInitialized;
1332
1330
await isStarted;
1333
1331
_checkIsolate ('resume' , isolateId);
1334
- return await (await debuggerFuture).resume (
1335
- step: step,
1336
- frameIndex: frameIndex,
1337
- );
1332
+ final debugger = await debuggerFuture;
1333
+ return await debugger.resume (step: step, frameIndex: frameIndex);
1338
1334
}, (result) => DwdsEvent .resume (step));
1335
+ } else {
1336
+ inspector.appConnection.runMain ();
1339
1337
}
1340
-
1338
+ // Finish the hot reload if needed.
1341
1339
if (_finishHotReloadOnResume != null ) {
1342
- await resumeWhenAppHasStarted ();
1343
1340
await _finishHotReloadOnResume !();
1344
1341
_finishHotReloadOnResume = null ;
1345
- return Success ();
1346
- }
1347
- if (inspector.appConnection.isStarted) {
1348
- return resumeWhenAppHasStarted ();
1349
- } else {
1350
- inspector.appConnection.runMain ();
1351
- return Success ();
1352
1342
}
1343
+ return Success ();
1353
1344
}
1354
1345
1355
1346
/// This method is deprecated in vm_service package.
0 commit comments