Skip to content

Commit 8fe2f37

Browse files
authored
Merge pull request #2343 from NativeScript/enable-v8-inspector
enable v8-inspector support
2 parents 3e307ba + 1fde378 commit 8fe2f37

File tree

1 file changed

+10
-26
lines changed

1 file changed

+10
-26
lines changed

lib/services/android-debug-service.ts

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import * as path from "path";
21
import * as net from "net";
32
import Future = require("fibers/future");
43
import { sleep } from "../common/helpers";
54
import {ChildProcess} from "child_process";
65

76
class AndroidDebugService implements IDebugService {
8-
private static DEFAULT_NODE_INSPECTOR_URL = "http://127.0.0.1:8080/debug";
9-
107
private _device: Mobile.IAndroidDevice = null;
118
private _debuggerClientProcess: ChildProcess;
129

@@ -78,8 +75,10 @@ class AndroidDebugService implements IDebugService {
7875
let port = -1;
7976
let forwardsResult = this.device.adb.executeCommand(["forward", "--list"]).wait();
8077

78+
let unixSocketName = `${packageName}-inspectorServer`;
79+
8180
//matches 123a188909e6czzc tcp:40001 localabstract:org.nativescript.testUnixSockets-debug
82-
let regexp = new RegExp(`(?:${deviceId} tcp:)([\\d]+)(?= localabstract:${packageName}-debug)`, "g");
81+
let regexp = new RegExp(`(?:${deviceId} tcp:)([\\d]+)(?= localabstract:${unixSocketName})`, "g");
8382
let match = regexp.exec(forwardsResult);
8483
if (match) {
8584
port = parseInt(match[1]);
@@ -92,7 +91,7 @@ class AndroidDebugService implements IDebugService {
9291
}
9392
port = candidatePort;
9493

95-
this.unixSocketForward(port, packageName + "-debug").wait();
94+
this.unixSocketForward(port, `${unixSocketName}`).wait();
9695
}
9796

9897
return port;
@@ -159,7 +158,6 @@ class AndroidDebugService implements IDebugService {
159158
if (this.$options.client) {
160159
let port = this.getForwardedLocalDebugPortForPackageName(deviceId, packageName).wait();
161160
this.startDebuggerClient(port).wait();
162-
this.openDebuggerClient(AndroidDebugService.DEFAULT_NODE_INSPECTOR_URL + "?port=" + port);
163161
}
164162
}).future<void>()();
165163
}
@@ -238,11 +236,12 @@ class AndroidDebugService implements IDebugService {
238236

239237
private startDebuggerClient(port: Number): IFuture<void> {
240238
return (() => {
241-
let nodeInspectorModuleFilePath = require.resolve("node-inspector");
242-
let nodeInspectorModuleDir = path.dirname(nodeInspectorModuleFilePath);
243-
let nodeInspectorFullPath = path.join(nodeInspectorModuleDir, "bin", "inspector");
244-
this._debuggerClientProcess = this.$childProcess.spawn(process.argv[0], [nodeInspectorFullPath, "--debug-port", port.toString()], { stdio: "ignore", detached: true });
245-
this.$processService.attachToProcessExitSignals(this, this.debugStop);
239+
//let nodeInspectorModuleFilePath = require.resolve("node-inspector");
240+
//let nodeInspectorModuleDir = path.dirname(nodeInspectorModuleFilePath);
241+
//let nodeInspectorFullPath = path.join(nodeInspectorModuleDir, "bin", "inspector");
242+
//this._debuggerClientProcess = this.$childProcess.spawn(process.argv[0], [nodeInspectorFullPath, "--debug-port", port.toString()], { stdio: "ignore", detached: true });
243+
//this.$processService.attachToProcessExitSignals(this, this.debugStop);
244+
this.$logger.info(`To start debugging, open the following URL in Chrome:\nchrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=localhost:${port}\n`);
246245
}).future<void>()();
247246
}
248247

@@ -253,20 +252,5 @@ class AndroidDebugService implements IDebugService {
253252
}
254253
}
255254

256-
private openDebuggerClient(url: string): void {
257-
let defaultDebugUI = "chrome";
258-
if (this.$hostInfo.isDarwin) {
259-
defaultDebugUI = "Google Chrome";
260-
}
261-
if (this.$hostInfo.isLinux) {
262-
defaultDebugUI = "google-chrome";
263-
}
264-
265-
let debugUI = this.$config.ANDROID_DEBUG_UI || defaultDebugUI;
266-
let child = this.$opener.open(url, debugUI);
267-
if (!child) {
268-
this.$errors.failWithoutHelp(`Unable to open ${debugUI}.`);
269-
}
270-
}
271255
}
272256
$injector.register("androidDebugService", AndroidDebugService);

0 commit comments

Comments
 (0)