Skip to content

Support lazily created SDK configurations. #1510

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 11 commits into from
Feb 18, 2022
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
10 changes: 6 additions & 4 deletions dwds/lib/dwds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import 'src/readers/asset_reader.dart';
import 'src/servers/devtools.dart';
import 'src/servers/extension_backend.dart';
import 'src/services/expression_compiler.dart';
import 'src/utilities/dart_uri.dart';
import 'src/utilities/sdk_configuration.dart';

export 'src/connections/app_connection.dart' show AppConnection;
export 'src/connections/debug_connection.dart' show DebugConnection;
Expand All @@ -50,6 +50,8 @@ export 'src/services/expression_compiler.dart'
show ExpressionCompilationResult, ExpressionCompiler, ModuleInfo;
export 'src/services/expression_compiler_service.dart'
show ExpressionCompilerService;
export 'src/utilities/sdk_configuration.dart'
show SdkConfiguration, SdkConfigurationProvider;

typedef ConnectionProvider = Future<ChromeConnection> Function();
typedef UrlEncoder = Future<String> Function(String url);
Expand Down Expand Up @@ -115,8 +117,7 @@ class Dwds {
bool enableDevtoolsLaunch,
DevtoolsLauncher devtoolsLauncher,
bool launchDevToolsInNewWindow,
Uri sdkDir,
Uri librariesPath,
SdkConfigurationProvider sdkConfigurationProvider,
bool emitDebugEvents,
}) async {
hostname ??= 'localhost';
Expand All @@ -131,7 +132,7 @@ class Dwds {
globalLoadStrategy = loadStrategy;
emitDebugEvents ??= true;

await DartUri.initialize(sdkDir: sdkDir, librariesPath: librariesPath);
sdkConfigurationProvider ??= DefaultSdkConfigurationProvider();

DevTools devTools;
Future<String> extensionUri;
Expand Down Expand Up @@ -188,6 +189,7 @@ class Dwds {
injected,
spawnDds,
launchDevToolsInNewWindow,
sdkConfigurationProvider,
);

return Dwds._(
Expand Down
6 changes: 6 additions & 0 deletions dwds/lib/src/debugging/inspector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import '../readers/asset_reader.dart';
import '../utilities/conversions.dart';
import '../utilities/dart_uri.dart';
import '../utilities/domain.dart';
import '../utilities/sdk_configuration.dart';
import '../utilities/shared.dart';
import 'classes.dart';
import 'debugger.dart';
Expand Down Expand Up @@ -64,6 +65,7 @@ class AppInspector extends Domain {

/// The root URI from which the application is served.
final String _root;
final SdkConfiguration _sdkConfiguration;

AppInspector._(
this.appConnection,
Expand All @@ -77,6 +79,7 @@ class AppInspector extends Domain {
this._locations,
this._root,
this._executionContext,
this._sdkConfiguration,
) : isolateRef = _toIsolateRef(isolate),
super.forInspector();

Expand All @@ -91,6 +94,7 @@ class AppInspector extends Domain {

var scripts = await scriptRefs;

await DartUri.initialize(_sdkConfiguration);
await DartUri.recordAbsoluteUris(libraries.map((lib) => lib.uri));
await DartUri.recordAbsoluteUris(scripts.map((script) => script.uri));

Expand All @@ -112,6 +116,7 @@ class AppInspector extends Domain {
String root,
Debugger debugger,
ExecutionContext executionContext,
SdkConfiguration sdkConfiguration,
) async {
var id = createId();
var time = DateTime.now().millisecondsSinceEpoch;
Expand Down Expand Up @@ -156,6 +161,7 @@ class AppInspector extends Domain {
locations,
root,
executionContext,
sdkConfiguration,
);
await appInspector._initialize();
return appInspector;
Expand Down
35 changes: 20 additions & 15 deletions dwds/lib/src/handlers/dev_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class DevHandler {
final bool _launchDevToolsInNewWindow;
final ExpressionCompiler _expressionCompiler;
final DwdsInjector _injected;
final SdkConfigurationProvider _sdkConfigurationProvider;

/// Null until [close] is called.
///
Expand All @@ -75,21 +76,23 @@ class DevHandler {
Stream<AppConnection> get connectedApps => _connectedApps.stream;

DevHandler(
this._chromeConnection,
this.buildResults,
this._devTools,
this._assetReader,
this._loadStrategy,
this._hostname,
this._extensionBackend,
this._urlEncoder,
this._useSseForDebugProxy,
this._useSseForInjectedClient,
this._serveDevTools,
this._expressionCompiler,
this._injected,
this._spawnDds,
this._launchDevToolsInNewWindow) {
this._chromeConnection,
this.buildResults,
this._devTools,
this._assetReader,
this._loadStrategy,
this._hostname,
this._extensionBackend,
this._urlEncoder,
this._useSseForDebugProxy,
this._useSseForInjectedClient,
this._serveDevTools,
this._expressionCompiler,
this._injected,
this._spawnDds,
this._launchDevToolsInNewWindow,
this._sdkConfigurationProvider,
) {
_subs.add(buildResults.listen(_emitBuildResults));
_listen();
if (_extensionBackend != null) {
Expand Down Expand Up @@ -210,6 +213,7 @@ class DevHandler {
useSse: false,
expressionCompiler: _expressionCompiler,
spawnDds: _spawnDds,
sdkConfigurationProvider: _sdkConfigurationProvider,
);
}

Expand Down Expand Up @@ -499,6 +503,7 @@ class DevHandler {
useSse: _useSseForDebugProxy,
expressionCompiler: _expressionCompiler,
spawnDds: _spawnDds,
sdkConfigurationProvider: _sdkConfigurationProvider,
);
var appServices = await _createAppDebugServices(
devToolsRequest.appId,
Expand Down
11 changes: 11 additions & 0 deletions dwds/lib/src/services/chrome_proxy_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ class ChromeProxyService implements VmServiceInterface {
final ExpressionCompiler _compiler;
ExpressionEvaluator _expressionEvaluator;

final SdkConfigurationProvider _sdkConfigurationProvider;

bool terminatingIsolates = false;

ChromeProxyService._(
Expand All @@ -106,6 +108,7 @@ class ChromeProxyService implements VmServiceInterface {
this._skipLists,
this.executionContext,
this._compiler,
this._sdkConfigurationProvider,
) {
var debugger = Debugger.create(
remoteDebugger,
Expand All @@ -126,6 +129,7 @@ class ChromeProxyService implements VmServiceInterface {
AppConnection appConnection,
ExecutionContext executionContext,
ExpressionCompiler expressionCompiler,
SdkConfigurationProvider sdkConfigurationProvider,
) async {
final vm = VM(
name: 'ChromeDebugProxy',
Expand Down Expand Up @@ -155,6 +159,7 @@ class ChromeProxyService implements VmServiceInterface {
skipLists,
executionContext,
expressionCompiler,
sdkConfigurationProvider,
);
unawaited(service.createIsolate(appConnection));
return service;
Expand Down Expand Up @@ -211,6 +216,7 @@ class ChromeProxyService implements VmServiceInterface {
// Issue: https://github.com/dart-lang/webdev/issues/1282
var debugger = await _debugger;
await _initializeEntrypoint(appConnection.request.entrypointPath);
var sdkConfiguration = await _sdkConfigurationProvider.configuration;

debugger.notifyPausedAtStart();
_inspector = await AppInspector.initialize(
Expand All @@ -221,6 +227,7 @@ class ChromeProxyService implements VmServiceInterface {
uri,
debugger,
executionContext,
sdkConfiguration,
);

_expressionEvaluator = _compiler == null
Expand Down Expand Up @@ -1035,6 +1042,10 @@ ${globalLoadStrategy.loadModuleSnippet}("dart_sdk").developer.invokeExtension(
String isolateId, String breakpointId, bool enable) =>
throw UnimplementedError();

@override
Future<Success> streamCpuSamplesWithUserTag(List<String> userTags) =>
throw UnimplementedError();

/// Prevent DWDS from blocking Dart SDK rolls if changes in package:vm_service
/// are unimplemented in DWDS.
@override
Expand Down
44 changes: 24 additions & 20 deletions dwds/lib/src/services/debug_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,28 +203,32 @@ class DebugService {
}

static Future<DebugService> start(
String hostname,
RemoteDebugger remoteDebugger,
ExecutionContext executionContext,
String tabUrl,
AssetReader assetReader,
LoadStrategy loadStrategy,
AppConnection appConnection,
UrlEncoder urlEncoder,
{void Function(Map<String, dynamic>) onRequest,
void Function(Map<String, dynamic>) onResponse,
bool spawnDds = true,
bool useSse,
ExpressionCompiler expressionCompiler}) async {
String hostname,
RemoteDebugger remoteDebugger,
ExecutionContext executionContext,
String tabUrl,
AssetReader assetReader,
LoadStrategy loadStrategy,
AppConnection appConnection,
UrlEncoder urlEncoder, {
void Function(Map<String, dynamic>) onRequest,
void Function(Map<String, dynamic>) onResponse,
bool spawnDds = true,
bool useSse,
ExpressionCompiler expressionCompiler,
SdkConfigurationProvider sdkConfigurationProvider,
}) async {
useSse ??= false;
var chromeProxyService = await ChromeProxyService.create(
remoteDebugger,
tabUrl,
assetReader,
loadStrategy,
appConnection,
executionContext,
expressionCompiler);
remoteDebugger,
tabUrl,
assetReader,
loadStrategy,
appConnection,
executionContext,
expressionCompiler,
sdkConfigurationProvider,
);
var authToken = _makeAuthToken();
var serviceExtensionRegistry = ServiceExtensionRegistry();
Handler handler;
Expand Down
Loading