Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 11c34cb

Browse files
juliandescottesjasonLaster
authored andcommitted
Avoid listing workers if connected to Fennec v59 (#5761)
1 parent aecd291 commit 11c34cb

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

src/client/firefox/commands.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ import { makePendingLocationId } from "../../utils/breakpoint";
3131

3232
import { createSource, createBreakpointLocation } from "./create";
3333

34+
import { getDeviceFront } from "./fronts-device";
35+
import { Services } from "devtools-modules";
36+
3437
let bpClients: BPClients;
3538
let threadClient: ThreadClient;
3639
let tabTarget: TabTarget;
@@ -317,14 +320,46 @@ async function fetchSources() {
317320
return sources.map(source => createSource(source, { supportsWasm }));
318321
}
319322

323+
/**
324+
* Temporary helper to check if the current server will support a call to
325+
* listWorkers. On Fennec 60 or older, the call will silently crash and prevent
326+
* the client from resuming.
327+
* XXX: Remove when FF60 for Android is no longer used or available.
328+
*
329+
* See https://bugzilla.mozilla.org/show_bug.cgi?id=1443550 for more details.
330+
*/
331+
async function checkServerSupportsListWorkers() {
332+
const root = await tabTarget.root;
333+
const deviceFront = await getDeviceFront(debuggerClient, root);
334+
const description = await deviceFront.getDescription();
335+
336+
const isFennec = description.apptype === "mobile/android";
337+
if (!isFennec) {
338+
// Explicitly return true early to avoid calling Services.vs.compare.
339+
// This would force us to extent the Services shim provided by
340+
// devtools-modules, used when this code runs in a tab.
341+
return true;
342+
}
343+
344+
// We are only interested in Fennec release versions here.
345+
// We assume that the server fix for Bug 1443550 will land in FF61.
346+
const version = description.platformversion;
347+
return Services.vc.compare(version, "61.0") >= 0;
348+
}
349+
320350
async function fetchWorkers(): Promise<{ workers: Worker[] }> {
351+
// Temporary workaround for Bug 1443550
352+
// XXX: Remove when FF60 for Android is no longer used or available.
353+
const supportsListWorkers = await checkServerSupportsListWorkers();
354+
321355
// NOTE: The Worker and Browser Content toolboxes do not have a parent
322356
// with a listWorkers function
323357
// TODO: there is a listWorkers property, but it is not a function on the
324358
// parent. Investigate what it is
325359
if (
326360
!threadClient._parent ||
327-
typeof threadClient._parent.listWorkers != "function"
361+
typeof threadClient._parent.listWorkers != "function" ||
362+
!supportsListWorkers
328363
) {
329364
return Promise.resolve({ workers: [] });
330365
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
4+
5+
export function getDeviceFront() {
6+
return {
7+
getDescription: function() {
8+
return {
9+
// Return anything that will not match Fennec v59
10+
apptype: "apptype",
11+
version: "version"
12+
};
13+
}
14+
};
15+
}

src/client/firefox/types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ export type TabTarget = {
241241
) => void
242242
},
243243
form: { consoleActor: any },
244+
root: any,
244245
activeTab: {
245246
navigateTo: string => Promise<*>,
246247
reload: () => Promise<*>

webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function buildConfig(envConfig) {
5858
extra.excludeMap = {
5959
"./source-editor": "devtools/client/sourceeditor/editor",
6060
"./test-flag": "devtools/shared/flags",
61+
"./fronts-device": "devtools/shared/fronts/device",
6162
react: "devtools/client/shared/vendor/react",
6263
redux: "devtools/client/shared/vendor/redux",
6364
"react-dom": "devtools/client/shared/vendor/react-dom",

0 commit comments

Comments
 (0)