Skip to content

Cherry-picked hotfix for chrome 100 update, updated version #1570

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
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
4 changes: 4 additions & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 12.1.1

- Hotfix: Fix missing `CallFrame.url` after update to Chrome 100.

## 12.1.0
- Update _fe_analyzer_shared to version ^34.0.0.

Expand Down
2 changes: 0 additions & 2 deletions dwds/debug_extension/web/background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,6 @@ void _filterAndForwardToBackend(Debuggee source, String method, Object params) {

if (debugSession == null) return;

if (method == 'Debugger.scriptParsed') return;

var event = _extensionEventFor(method, params);

debugSession.socketClient.sink.add(jsonEncode(serializers.serialize(event)));
Expand Down
8,327 changes: 4,146 additions & 4,181 deletions dwds/debug_extension/web/background.js

Large diffs are not rendered by default.

28 changes: 24 additions & 4 deletions dwds/lib/src/debugging/debugger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,22 @@ class Debugger extends Domain {
}
}

/// Returns Chrome script uri for Chrome script ID.
String _urlForScriptId(String scriptId) =>
_remoteDebugger.scripts[scriptId]?.url;

/// Returns source [Location] for the paused event.
///
/// If we do not have [Location] data for the embedded JS location, null is
/// returned.
Future<Location> _sourceLocation(DebuggerPausedEvent e) {
var frame = e.params['callFrames'][0];
var location = frame['location'];
return _locations.locationForJs(
frame['url'] as String, (location['lineNumber'] as int) + 1);
var scriptId = location['scriptId'] as String;
var lineNumber = location['lineNumber'] as int;

var url = _urlForScriptId(scriptId);
return _locations.locationForJs(url, lineNumber + 1);
}

/// The variables visible in a frame in Dart protocol [BoundVariable] form.
Expand Down Expand Up @@ -448,10 +455,17 @@ class Debugger extends Domain {
// Chrome is 0 based. Account for this.
var line = location.lineNumber + 1;
var column = location.columnNumber + 1;

var url = _urlForScriptId(location.scriptId);
if (url == null) {
logger.severe('Failed to create dart frame for ${frame.functionName}: '
'cannot find location for script ${location.scriptId}');
}

// TODO(sdk/issues/37240) - ideally we look for an exact location instead
// of the closest location on a given line.
Location bestLocation;
for (var location in await _locations.locationsForUrl(frame.url)) {
for (var location in await _locations.locationsForUrl(url)) {
if (location.jsLocation.line == line) {
bestLocation ??= location;
if ((location.jsLocation.column - column).abs() <
Expand Down Expand Up @@ -551,8 +565,14 @@ class Debugger extends Domain {
// If we don't have source location continue stepping.
if (_isStepping && (await _sourceLocation(e)) == null) {
var frame = e.params['callFrames'][0];
var url = '${frame["url"]}';
var scriptId = '${frame["location"]["scriptId"]}';

var url = _urlForScriptId(scriptId);
if (url == null) {
logger.severe('Stepping failed: '
'cannot find location for script $scriptId');
}

// TODO(grouma) - In the future we should send all previously computed
// skipLists.
await _remoteDebugger.stepInto(params: {
Expand Down
6 changes: 0 additions & 6 deletions dwds/lib/src/debugging/modules.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ class Modules {
final _sourceToLibrary = <String, Uri>{};
var _moduleMemoizer = AsyncMemoizer<void>();

// The Chrome script ID to corresponding module.
final _scriptIdToModule = <String, String>{};

final Map<String, String> _libraryToModule = {};

String _entrypoint;
Expand All @@ -43,9 +40,6 @@ class Modules {
_entrypoint = entrypoint;
}

/// Returns the module for the Chrome script ID.
String moduleForScriptId(String scriptId) => _scriptIdToModule[scriptId];

/// Returns the containing module for the provided Dart server path.
Future<String> moduleForSource(String serverPath) async {
await _moduleMemoizer.runOnce(_initializeMapping);
Expand Down
Loading