Skip to content

Shows an overlay "Paused in Dart DevTools" when paused at a breakpoint #1476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions dwds/lib/src/debugging/debugger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class Debugger extends Domain {

PauseState _pauseState = PauseState.none;

bool _pausedOverlayVisible = false;

String get pauseState => _pauseModePauseStates.entries
.firstWhere((entry) => entry.value == _pauseState)
.key;
Expand Down Expand Up @@ -392,6 +394,25 @@ class Debugger extends Domain {
return await inspector.jsCallFunctionOn(receiver, expression, args);
}

// Renders the paused at breakpoint overlay over the application.
void _showPausedOverlay() async {
if (_pausedOverlayVisible) return;
handleErrorIfPresent(await _remoteDebugger?.sendCommand('DOM.enable'));
handleErrorIfPresent(await _remoteDebugger?.sendCommand('Overlay.enable'));
handleErrorIfPresent(await _remoteDebugger
?.sendCommand('Overlay.setPausedInDebuggerMessage', params: {
'message': 'Paused in Dart DevTools',
}));
_pausedOverlayVisible = true;
}

// Removes the paused at breakpoint overlay from the application.
void _hidePausedOverlay() async {
if (!_pausedOverlayVisible) return;
handleErrorIfPresent(await _remoteDebugger?.sendCommand('Overlay.disable'));
_pausedOverlayVisible = false;
}

/// Calls the Chrome Runtime.getProperties API for the object with [objectId].
///
/// Note that the property names are JS names, e.g.
Expand Down Expand Up @@ -563,6 +584,7 @@ class Debugger extends Domain {
logger.warning('Error calculating Dart frames', e, s);
}

_showPausedOverlay();
isolate.pauseEvent = event;
_streamNotify('Debug', event);
}
Expand All @@ -579,6 +601,8 @@ class Debugger extends Domain {
kind: EventKind.kResume,
timestamp: DateTime.now().millisecondsSinceEpoch,
isolate: inspector.isolateRef);

_hidePausedOverlay();
isolate.pauseEvent = event;
_streamNotify('Debug', event);
}
Expand Down