Skip to content

Commit

Permalink
Preparation for hotfix release 19.0.1+1 (#2186)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliette authored Aug 9, 2023
1 parent 91cbd18 commit e112af7
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 71 deletions.
4 changes: 4 additions & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 19.0.1+1

- Fix for Flutter crash when resuming and app is not paused. - [#132160](https://github.com/flutter/flutter/issues/132160)

## 19.0.1

- Do not show async frame errors on evaluation. - [#2073](https://github.com/dart-lang/webdev/pull/2073)
Expand Down
61 changes: 37 additions & 24 deletions dwds/lib/src/debugging/debugger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,32 +121,45 @@ class Debugger extends Domain {
/// Note that stepping will automatically continue until Chrome is paused at
/// a location for which we have source information.
Future<Success> resume({String? step, int? frameIndex}) async {
if (frameIndex != null) {
throw ArgumentError('FrameIndex is currently unsupported.');
}
WipResponse? result;
if (step != null) {
_isStepping = true;
switch (step) {
case 'Over':
result = await _remoteDebugger.stepOver();
break;
case 'Out':
result = await _remoteDebugger.stepOut();
break;
case 'Into':
result = await _remoteDebugger.stepInto();
break;
default:
throwInvalidParam('resume', 'Unexpected value for step: $step');
try {
if (frameIndex != null) {
throw ArgumentError('FrameIndex is currently unsupported.');
}
} else {
_isStepping = false;
_previousSteppingLocation = null;
result = await _remoteDebugger.resume();
WipResponse? result;
if (step != null) {
_isStepping = true;
switch (step) {
case 'Over':
result = await _remoteDebugger.stepOver();
break;
case 'Out':
result = await _remoteDebugger.stepOut();
break;
case 'Into':
result = await _remoteDebugger.stepInto();
break;
default:
throwInvalidParam('resume', 'Unexpected value for step: $step');
}
} else {
_isStepping = false;
_previousSteppingLocation = null;
result = await _remoteDebugger.resume();
}
handleErrorIfPresent(result);
return Success();
} on WipError catch (e) {
final errorMessage = e.message;
if (errorMessage != null &&
errorMessage.contains('Can only perform operation while paused')) {
throw RPCError(
'resume',
RPCErrorKind.kIsolateMustBePaused.code,
errorMessage,
);
}
rethrow;
}
handleErrorIfPresent(result);
return Success();
}

/// Returns the current Dart stack for the paused debugger.
Expand Down
41 changes: 14 additions & 27 deletions dwds/lib/src/services/chrome_proxy_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1088,33 +1088,20 @@ ${globalLoadStrategy.loadModuleSnippet}("dart_sdk").developer.invokeExtension(
String? step,
int? frameIndex,
}) async {
try {
if (inspector.appConnection.isStarted) {
return captureElapsedTime(
() async {
await isInitialized;
await isStarted;
_checkIsolate('resume', isolateId);
return await (await debuggerFuture)
.resume(step: step, frameIndex: frameIndex);
},
(result) => DwdsEvent.resume(step),
);
} else {
inspector.appConnection.runMain();
return Success();
}
} on WipError catch (e) {
final errorMessage = e.message;
if (errorMessage != null &&
errorMessage.contains('Can only perform operation while paused')) {
throw RPCError(
'resume',
RPCErrorKind.kIsolateMustBePaused.code,
errorMessage,
);
}
rethrow;
if (inspector.appConnection.isStarted) {
return captureElapsedTime(
() async {
await isInitialized;
await isStarted;
_checkIsolate('resume', isolateId);
return await (await debuggerFuture)
.resume(step: step, frameIndex: frameIndex);
},
(result) => DwdsEvent.resume(step),
);
} else {
inspector.appConnection.runMain();
return Success();
}
}

Expand Down
2 changes: 1 addition & 1 deletion dwds/lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dwds/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: dwds
# Every time this changes you need to run `dart run build_runner build`.
version: 19.0.1
version: 19.0.1+1
description: >-
A service that proxies between the Chrome debug protocol and the Dart VM
service protocol.
Expand Down
10 changes: 8 additions & 2 deletions dwds/test/chrome_proxy_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1368,12 +1368,18 @@ void main() {
expect(pauseBreakpoints, hasLength(1));
expect(pauseBreakpoints.first.id, bp.id);
await service.removeBreakpoint(isolateId!, bp.id!);
});

tearDown(() async {
// Resume execution to not impact other tests.
await service.resume(isolateId!);
});

test('resuming throws kIsolateMustBePaused error if not paused',
() async {
await expectLater(
service.resume(isolateId!),
throwsRPCErrorWithCode(RPCErrorKind.kIsolateMustBePaused.code),
);
});
});

group('Step', () {
Expand Down
2 changes: 1 addition & 1 deletion dwds/test/devtools_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void main() {
final devToolsWindow =
windows.firstWhere((window) => window != newAppWindow);
await devToolsWindow.setAsActive();
expect(await context.webDriver.title, equals('Dart DevTools'));
expect(await context.webDriver.pageSource, contains('DevTools'));
});

test(
Expand Down
34 changes: 19 additions & 15 deletions dwds/test/events_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,25 @@ void main() {
await context.tearDown();
});

test('emits DEBUGGER_READY and DEVTOOLS_LOAD events', () async {
await expectEventsDuring(
[
matchesEvent(DwdsEventKind.debuggerReady, {
'elapsedMilliseconds': isNotNull,
'screen': equals('debugger'),
}),
matchesEvent(DwdsEventKind.devToolsLoad, {
'elapsedMilliseconds': isNotNull,
'screen': equals('debugger'),
}),
],
() => keyboard.sendChord([Keyboard.alt, 'd']),
);
});
test(
'emits DEBUGGER_READY and DEVTOOLS_LOAD events',
() async {
await expectEventsDuring(
[
matchesEvent(DwdsEventKind.debuggerReady, {
'elapsedMilliseconds': isNotNull,
'screen': equals('debugger'),
}),
matchesEvent(DwdsEventKind.devToolsLoad, {
'elapsedMilliseconds': isNotNull,
'screen': equals('debugger'),
}),
],
() => keyboard.sendChord([Keyboard.alt, 'd']),
);
},
skip: 'https://github.com/dart-lang/webdev/issues/2181',
);

test('emits DEVTOOLS_LAUNCH event', () async {
await expectEventDuring(
Expand Down
4 changes: 4 additions & 0 deletions dwds/test/fixtures/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ Matcher isRPCErrorWithMessage(String message) =>
Matcher throwsRPCErrorWithMessage(String message) =>
throwsA(isRPCErrorWithMessage(message));

Matcher isRPCErrorWithCode(int code) =>
isA<RPCError>().having((e) => e.code, 'code', equals(code));
Matcher throwsRPCErrorWithCode(int code) => throwsA(isRPCErrorWithCode(code));

enum CompilationMode { buildDaemon, frontendServer }

class TestContext {
Expand Down

0 comments on commit e112af7

Please sign in to comment.