Skip to content

Show a warning in the Dart Debug Extension when a user tries to debug a sharded Dart app #1462

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 13 commits into from
Dec 10, 2021
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
6 changes: 5 additions & 1 deletion dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 11.5.2-dev

- Show an alert in the Dart Debug Extension for a multi-app scenario.

## 11.5.1

- Update SDK contraint to `>=2.15.0 <3.0.0`.
Expand All @@ -18,7 +22,7 @@
- Fix chrome detection in iPhone emulation mode in chrome or edge browsers.
- Reliably find unused port for extension backend http service.
- Ignore offset / count parameters in getObject if the object has no length.
- Include static member information for classes
- Include static member information for classes.

## 11.4.0

Expand Down
5 changes: 4 additions & 1 deletion dwds/debug_extension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
## 1.24

- Detect Dart applications in multi-app environments and show an alert.

## 1.23

- Depend on the latest `package:sse` to improve stability of the connection with many
concurrent requests.


## 1.22

- Detect Dart applications and update the icon accordingly.
Expand Down
2 changes: 1 addition & 1 deletion dwds/debug_extension/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: extension
publish_to: none
version: 1.23.0
version: 1.24.0
author: Dart Team <[email protected]>
homepage: https://github.com/dart-lang/webdev
description: >-
Expand Down
27 changes: 26 additions & 1 deletion dwds/debug_extension/web/background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const _allowedEvents = {'Overlay.inspectNodeRequested'};
// Map of Chrome tab ID to encoded vm service protocol URI.
final _tabIdToEncodedUri = <int, String>{};

// Map of Chrome tab ID to warnings for that tab.
final _tabIdToWarning = <int, String>{};

final _debuggableTabs = <int>{};

final _tabsToAttach = <Tab>{};
Expand Down Expand Up @@ -67,6 +70,12 @@ void main() {
var callback = allowInterop((List<Tab> tabs) async {
currentTab = tabs[0];
if (!_debuggableTabs.contains(currentTab.id)) return;

if (_tabIdToWarning.containsKey(currentTab.id)) {
alert(_tabIdToWarning[currentTab.id]);
return;
}

attach(Debuggee(tabId: currentTab.id), '1.3', allowInterop(() async {
if (lastError != null) {
String alertMessage;
Expand Down Expand Up @@ -100,6 +109,10 @@ void main() {

onMessageAddListener(allowInterop(
(Request request, Sender sender, Function sendResponse) async {
// Register any warnings for the tab:
if (request.warning != '') {
_tabIdToWarning[sender.tab.id] = request.warning;
}
_debuggableTabs.add(sender.tab.id);
_updateIcon();
// TODO(grouma) - We can conditionally auto start debugging here.
Expand Down Expand Up @@ -362,9 +375,20 @@ void _updateIcon() {
var query = QueryInfo(active: true, currentWindow: true);
queryTabs(query, allowInterop((List tabs) {
var tabList = List<Tab>.from(tabs);
if (tabList.isEmpty || _debuggableTabs.contains(tabList.first.id)) {
// If tabList is empty, the user has likely navigated to a different window.
// Therefore, do not update the icon:
if (tabList.isEmpty || tabList.first == null || tabList.first.id == null) {
return;
}

if (_tabIdToWarning.containsKey(tabList.first.id)) {
// Set the warning icon (red):
setIcon(IconInfo(path: 'dart_warning.png'));
} else if (_debuggableTabs.contains(tabList.first.id)) {
// Set the debuggable icon (blue):
setIcon(IconInfo(path: 'dart.png'));
} else {
// Set the default icon (grey):
setIcon(IconInfo(path: 'dart_grey.png'));
}
}));
Expand Down Expand Up @@ -514,6 +538,7 @@ class Request {
external int get tabId;
external String get name;
external dynamic get options;
external String get warning;
external factory Request({int tabId, String name, dynamic options});
}

Expand Down
Loading