Description
Spinning this off of dart-lang/webdev#2257, although this issue involves work for other systems besides DevTools. But I would like everything to be tracked in one place.
This all began because on web we were experiencing an issue of "phantom breakpoints" where a breakpoint that a user had removed was still being hit in Chrome, see dart-lang/webdev#2257. We would like to remove that behavior and have the debugging clients be the source of truth for breakpoints. However, while DAP clients re-establish breakpoints on hot-restart, DevTools does not.
On further investigation, we discovered that breakpoints set along the app's initial startup path in DevTools and in DAP clients don't always get hit on hot-restart or (for web) when users refresh the page. This is because breakpoints are re-set by the debugging client after the app's isolate has already started. Therefore, we want to use a combination of:
set_isolates_paused_on_start
- make sure the app initially starts out pausedrequirePermissionToResume(onPauseStart: true)
- make sure that all connected debugging clients usingset_isolates_paused_on_start
sendresume
event before resuming- debugging clients send
resume
after they have set breakpoints
Therefore, the work required here:
Note: the following needs to be done before rolling unpinning DWDS and rolling it into google3. It was pinned here: dart-lang/sdk@4642c73
In DWDS:
- Remove the logic to re-establish breakpoints after a hot-restart from DWDS (DONE: Do not persist breakpoints across hot restarts or page refreshes dart-lang/webdev#2371)
- DWDS needs to implement the VM Service
setFlag
method forpause_isolates_on_start
(DONE: ImplementsetFlag
for 'pause_isolates_on_start' dart-lang/webdev#2373) - During hot-restart, wait to run
main
ifpause-isolates-on-start
istrue
(DONE: During hot-restart, wait to runmain
whenpause_isolates_on_start
is true dart-lang/webdev#2378) - After the debugger disconnects, ensure that we no longer pause for hot-restarts/page reloads (DONE: Fix reading
pause_isolates_on_start
value from the DWDS dart-lang/webdev#2398) - Follow-up: Make
pauseIsolatesOnStart
optional (DONE: MakepauseIsolatesOnStart
an optional parameter to hot-restart dart-lang/webdev#2397) - Follow-up: Send a
kPausePostRequest
event after restarting to notify clients to resume (DONE: Send akPausePostRequest
after restarting to notify clients to resume dart-lang/webdev#2441) - Follow-up: Implement the
getFlagList
API (DONE: Implement the VM servicegetFlagList
API dart-lang/webdev#2438)
In DevTools:
- Add logic to re-establish breakpoints after a hot-restart to DevTools (DONE: Re-establish breakpoints on hot-restart #7205)
- Call
setFlag('pause_isolates_on_start')
andrequirePermissionToResume(onPauseStart: true)
, then only resume once breakpoints are set (DONE: Configure DevTools to pause isolates on hot restart, and then only resume once breakpoints have been set #7234)
In DDS:
- Add
requireUserPermissionToResume
andreadyToResume
(DONE BY @bkonyi): dart-lang/sdk@5536951) - Determine initial
requireUserPermissionToResume
values from the VM service flags (DONE: dart-lang/sdk@9382e58)
Note: This can be done after rolling DWDS into google3
In Flutter Engine:
[ ] Make surepause_isolates_on_start
is respected (see Setting flagpause_isolates_on_start
does not pause isolates on hot-restart dart-lang/sdk#54900, currently flutter_engine isn't respecting the flag so setting it in the VM Service doesn't do anything)
In DAP:
- Set
requirePermissionToResume
andrequireUserPermissionToResume
foronPauseStart
andonPauseExit
so that DDS waits for DAP's permission before resuming the isolate (DONE: dart-lang/sdk@93556ae)
Make sure pause_isolates_on_start
is respected for hot-restarts and page refreshes for web (changes required in multiple locations):
- Page refresh when running from
flutter_tools
(DONE:: Wait for aresume
event to run themain()
method after a page refresh dart-lang/webdev#2431) - hot-restart when running from
flutter_tools
(DONE: During hot-restart, wait to runmain
whenpause_isolates_on_start
is true dart-lang/webdev#2378) - Hot-restart and page-refreshes in g3: (DONE: b/335227246)
- Mirror of hot-restart in g3 (DONE: https://dart-review.googlesource.com/c/sdk/+/355880)