use of org.dartlang.vm.service.VmService in project flutter-intellij by flutter.
the class DartVmServiceDebugProcessZ method scheduleConnectNew.
public void scheduleConnectNew() {
ApplicationManager.getApplication().executeOnPooledThread(() -> {
// Poll, waiting for "flutter run" to give us a websocket.
// Don't use a timeout - the user can cancel manually the operation.
String url = myConnector.getWebSocketUrl();
while (url == null) {
if (getSession().isStopped())
return;
TimeoutUtil.sleep(100);
url = myConnector.getWebSocketUrl();
}
if (getSession().isStopped()) {
return;
}
// "Flutter run" has given us a websocket; we can assume it's ready immediately,
// because "flutter run" has already connected to it.
final VmService vmService;
final VmOpenSourceLocationListener vmOpenSourceLocationListener;
try {
vmService = VmService.connect(url);
vmOpenSourceLocationListener = VmOpenSourceLocationListener.connect(url);
} catch (IOException e) {
onConnectFailed("Failed to connect to the VM observatory service at: " + url + "\n" + e.toString() + "\n" + formatStackTraces(e));
return;
}
onConnectSucceeded(vmService, vmOpenSourceLocationListener);
});
}
use of org.dartlang.vm.service.VmService in project flutter-intellij by flutter.
the class VmServiceWidgetPerfProvider method setupConnection.
private void setupConnection(@NotNull VmService vmService) {
if (isDisposed || connected) {
return;
}
final VMServiceManager vmServiceManager = app.getVMServiceManager();
assert vmServiceManager != null;
connected = true;
isolateRefStreamSubscription = vmServiceManager.getCurrentFlutterIsolate((isolateRef) -> requestRepaint(When.soon), false);
vmService.addVmServiceListener(new VmServiceListenerAdapter() {
@Override
public void received(String streamId, Event event) {
onVmServiceReceived(streamId, event);
}
@Override
public void connectionClosed() {
}
});
inspectorService = InspectorService.create(app, app.getFlutterDebugProcess(), app.getVmService());
inspectorService.whenCompleteAsync((service, throwable) -> Disposer.register(this, service));
requestRepaint(When.soon);
}
use of org.dartlang.vm.service.VmService in project flutter-intellij by flutter.
the class DartVmServiceDebugProcess method scheduleConnect.
public void scheduleConnect() {
ApplicationManager.getApplication().executeOnPooledThread(() -> {
// Poll, waiting for "flutter run" to give us a websocket.
// Don't use a timeout - the user can cancel manually the operation.
String url = myConnector.getWebSocketUrl();
while (url == null) {
if (getSession().isStopped())
return;
TimeoutUtil.sleep(100);
url = myConnector.getWebSocketUrl();
}
if (getSession().isStopped()) {
return;
}
// "flutter run" has given us a websocket; we can assume it's ready immediately, because
// "flutter run" has already connected to it.
final VmService vmService;
try {
vmService = VmService.connect(url);
} catch (IOException | RuntimeException e) {
onConnectFailed("Failed to connect to the VM observatory service at: " + url + "\n" + e.toString() + "\n" + formatStackTraces(e));
return;
}
onConnectSucceeded(vmService);
});
}
use of org.dartlang.vm.service.VmService in project flutter-intellij by flutter.
the class DartVmServiceDebugProcess method onConnectSucceeded.
private void onConnectSucceeded(VmService vmService) {
final DartVmServiceListener vmServiceListener = new DartVmServiceListener(this, (DartVmServiceBreakpointHandler) myBreakpointHandlers[0]);
final DartVmServiceBreakpointHandler breakpointHandler = (DartVmServiceBreakpointHandler) myBreakpointHandlers[0];
myVmServiceWrapper = new VmServiceWrapper(this, vmService, vmServiceListener, myIsolatesInfo, breakpointHandler);
final ScriptProvider provider = (isolateId, scriptId) -> myVmServiceWrapper.getScriptSync(isolateId, scriptId);
mapper.onConnect(provider, myConnector.getRemoteBaseUrl());
final FlutterLaunchMode launchMode = FlutterLaunchMode.fromEnv(executionEnvironment);
if (launchMode.supportsDebugConnection()) {
myVmServiceWrapper.handleDebuggerConnected();
// TODO(jacobr): the following code is a workaround for issues
// auto-resuming isolates paused at their creation while running in
// debug mode.
// The ideal fix would by to fix VMServiceWrapper so that it checks
// for already running isolates like we do here or to refactor where we
// create our VmServiceWrapper so we can listen for isolate creation soon
// enough that we never miss an isolate creation message.
vmService.getVM(new VMConsumer() {
@Override
public void received(VM vm) {
final ElementList<IsolateRef> isolates = vm.getIsolates();
// to handleDebuggerConnected was made and so
for (IsolateRef isolateRef : isolates) {
vmService.getIsolate(isolateRef.getId(), new VmServiceConsumers.GetIsolateConsumerWrapper() {
public void received(Isolate isolate) {
final Event event = isolate.getPauseEvent();
final EventKind eventKind = event.getKind();
if (eventKind == EventKind.PauseStart) {
ApplicationManager.getApplication().invokeLater(() -> {
// We are assuming it is safe to call handleIsolate multiple times.
myVmServiceWrapper.handleIsolate(isolateRef, true);
});
} else if (eventKind == EventKind.Resume) {
// Currently true if we got here via 'flutter attach'
ApplicationManager.getApplication().invokeLater(() -> {
myVmServiceWrapper.attachIsolate(isolateRef, isolate);
});
}
}
});
}
}
@Override
public void onError(RPCError error) {
FlutterUtils.warn(LOG, error.toString());
}
});
}
vmService.addVmServiceListener(vmServiceListener);
myVmConnected = true;
getSession().rebuildViews();
onVmConnected(vmService);
}
Aggregations