Skip to content

Commit f3bae6f

Browse files
Merge pull request #4231 from NativeScript/vladimirov/ios-debug-bundled
fix: `tns debug ios --hmr` does not refresh DevTools
2 parents 92e4426 + 8a76625 commit f3bae6f

File tree

4 files changed

+14
-24
lines changed

4 files changed

+14
-24
lines changed

lib/services/android-device-debug-service.ts

-8
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,6 @@ export class AndroidDeviceDebugService extends DebugServiceBase implements IDevi
5959
return this.removePortForwarding();
6060
}
6161

62-
protected getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string {
63-
const debugOpts = _.cloneDeep(debugOptions);
64-
debugOpts.useBundledDevTools = debugOpts.useBundledDevTools === undefined ? true : debugOpts.useBundledDevTools;
65-
66-
const chromeDebugUrl = super.getChromeDebugUrl(debugOpts, port);
67-
return chromeDebugUrl;
68-
}
69-
7062
private async debugOnEmulator(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
7163
// Assure we've detected the emulator as device
7264
// For example in case deployOnEmulator had stated new emulator instance

lib/services/debug-service-base.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,16 @@ export abstract class DebugServiceBase extends EventEmitter implements IDeviceDe
3434

3535
protected getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string {
3636
// corresponds to 55.0.2883 Chrome version
37+
// SHA is taken from https://chromium.googlesource.com/chromium/src/+/55.0.2883.100
38+
// This SHA is old and does not support debugging with HMR.
39+
// In case we want to stick with concrete SHA, get it from one of the tags https://chromium.googlesource.com/chromium/src/
40+
// IMPORTANT: When you get the SHA, ensure you are using the `parent` commit, not the actual one.
41+
// Using the actual commit will result in 404 error in the remote serve.
3742
const commitSHA = debugOptions.devToolsCommit || "02e6bde1bbe34e43b309d4ef774b1168d25fd024";
38-
debugOptions.useHttpUrl = debugOptions.useHttpUrl === undefined ? false : debugOptions.useHttpUrl;
3943

4044
let chromeDevToolsPrefix = `chrome-devtools://devtools/remote/serve_file/@${commitSHA}`;
4145

42-
if (debugOptions.useBundledDevTools) {
46+
if (debugOptions.useBundledDevTools === undefined || debugOptions.useBundledDevTools) {
4347
chromeDevToolsPrefix = "chrome-devtools://devtools/bundled";
4448
}
4549

lib/services/ios-device-debug-service.ts

-8
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ export class IOSDeviceDebugService extends DebugServiceBase implements IDeviceDe
6161
await this.stopAppDebuggerOnSimulator();
6262
}
6363

64-
protected getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string {
65-
const debugOpts = _.cloneDeep(debugOptions);
66-
debugOpts.useBundledDevTools = debugOpts.useBundledDevTools === undefined ? false : debugOpts.useBundledDevTools;
67-
68-
const chromeDebugUrl = super.getChromeDebugUrl(debugOpts, port);
69-
return chromeDebugUrl;
70-
}
71-
7264
private async startApp(debugData: IDebugData, debugOptions: IDebugOptions) {
7365
if (this.device.isEmulator) {
7466
await this.startAppOnSimulator(debugData, debugOptions);

test/services/ios-device-debug-service.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe("iOSDeviceDebugService", () => {
7878
{
7979
scenarioName: "useBundledDevTools and useHttpUrl are not passed",
8080
debugOptions: {},
81-
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
81+
expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
8282
},
8383

8484
// When useBundledDevTools is true
@@ -137,7 +137,7 @@ describe("iOSDeviceDebugService", () => {
137137
debugOptions: {
138138
useHttpUrl: false
139139
},
140-
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
140+
expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
141141
},
142142
{
143143
scenarioName: "useBundledDevTools is not passed and useHttpUrl is true",
@@ -149,16 +149,18 @@ describe("iOSDeviceDebugService", () => {
149149

150150
// devToolsCommit tests
151151
{
152-
scenarioName: "devToolsCommit defaults to ${expectedDevToolsCommitSha} and is used in result when useBundledDevTools is not passed",
153-
debugOptions: {},
152+
scenarioName: `devToolsCommit defaults to ${expectedDevToolsCommitSha} and is used in result when useBundledDevTools is not passed`,
153+
debugOptions: {
154+
useBundledDevTools: false
155+
},
154156
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
155157
},
156158
{
157-
scenarioName: "devToolsCommit is set to passed value when useBundledDevTools is not passed",
159+
scenarioName: "devToolsCommit is disregarded when useBundledDevTools is not passed",
158160
debugOptions: {
159161
devToolsCommit: customDevToolsCommit
160162
},
161-
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${customDevToolsCommit}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
163+
expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
162164
},
163165
{
164166
scenarioName: "devToolsCommit is set to passed value when useBundledDevTools is set to false",

0 commit comments

Comments
 (0)