@@ -473,8 +473,9 @@ class ChromeProxyService implements VmServiceInterface {
473473 if (! _isIsolateRunning) return ;
474474 final isolate = inspector.isolate;
475475
476+ final debugger = await debuggerFuture;
476477 for (final breakpoint in isolate.breakpoints? .toList () ?? < Breakpoint > []) {
477- await ( await debuggerFuture) .removeBreakpoint (breakpoint.id! );
478+ await debugger .removeBreakpoint (breakpoint.id! );
478479 }
479480 }
480481
@@ -1210,43 +1211,7 @@ class ChromeProxyService implements VmServiceInterface {
12101211 returnByValue: true ,
12111212 );
12121213
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) {
12501215 // Finish hot reload immediately.
12511216 _logger.info ('Issuing \$ dartHotReloadEndDwds request' );
12521217 await inspector.jsEvaluate (
@@ -1257,7 +1222,40 @@ class ChromeProxyService implements VmServiceInterface {
12571222 // TODO(srujzs): Supposedly Dart DevTools uses a kIsolateReload event
12581223 // for breakpoints? We should confirm and add tests before sending the
12591224 // event.
1225+ return ;
12601226 }
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+ );
12611259 }
12621260
12631261 /// Performs a WebSocket-based hot reload by sending a request and waiting for a response.
@@ -1319,37 +1317,30 @@ class ChromeProxyService implements VmServiceInterface {
13191317 String ? step,
13201318 int ? frameIndex,
13211319 }) 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.
13251322 if (_resumeAfterRestartEventsController.hasListener) {
13261323 _resumeAfterRestartEventsController.add (isolateId);
13271324 return Success ();
13281325 }
1329- Future <Success > resumeWhenAppHasStarted () {
1330- return captureElapsedTime (() async {
1326+
1327+ if (inspector.appConnection.isStarted) {
1328+ await captureElapsedTime (() async {
13311329 await isInitialized;
13321330 await isStarted;
13331331 _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);
13381334 }, (result) => DwdsEvent .resume (step));
1335+ } else {
1336+ inspector.appConnection.runMain ();
13391337 }
1340-
1338+ // Finish the hot reload if needed.
13411339 if (_finishHotReloadOnResume != null ) {
1342- await resumeWhenAppHasStarted ();
13431340 await _finishHotReloadOnResume !();
13441341 _finishHotReloadOnResume = null ;
1345- return Success ();
1346- }
1347- if (inspector.appConnection.isStarted) {
1348- return resumeWhenAppHasStarted ();
1349- } else {
1350- inspector.appConnection.runMain ();
1351- return Success ();
13521342 }
1343+ return Success ();
13531344 }
13541345
13551346 /// This method is deprecated in vm_service package.
0 commit comments