Skip to content

Support hot restart for multi-ddr scenario #1442

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
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 11.5.0-dev

- Support hot restart in a multi-app scenario with legacy modules.
- Rename `$dartHotRestart` in the injected client to `$dartHotRestartDwds`.
- Make `$dartHotRestartDwds` take a `runId`.
- No change in behavior for single applications.
- For a multi-app scenario using legacy modules, this will make all
sub-apps with the same `runId` restart at the same time once.

Note that multi-app scenario is currently only supported for legacy modules,
used by DDR, and is not yet supported for amd modules that are used by
flutter tools and webdev.

## 11.4.0

- Fix duplicated scripts returned by `VmService.getScripts` API.
Expand Down
9 changes: 6 additions & 3 deletions dwds/lib/src/dwds_vm_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'dart:async';
import 'dart:convert';

import 'package:logging/logging.dart';
import 'package:uuid/uuid.dart';
import 'package:vm_service/vm_service.dart';
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';

Expand Down Expand Up @@ -194,14 +195,16 @@ Future<Map<String, dynamic>> _hotRestart(
// restart. Only return success after the isolate has fully started.
var stream = chromeProxyService.onEvent('Isolate');
try {
_logger.info('Issuing \$dartHotRestart request.');
// Generate run id to hot restart all apps loaded into the tab.
var runId = const Uuid().v4().toString();
_logger.info('Issuing \$dartHotRestartDwds request');
await chromeProxyService.remoteDebugger
.sendCommand('Runtime.evaluate', params: {
'expression': r'$dartHotRestart();',
'expression': '\$dartHotRestartDwds(\'$runId\');',
'awaitPromise': true,
'contextId': context,
});
_logger.info('\$dartHotRestart request complete.');
_logger.info('\$dartHotRestartDwds request complete.');
} on WipError catch (exception) {
var code = exception.error['code'];
// This corresponds to `Execution context was destroyed` which can
Expand Down
Loading