Bug 1537657 - Detach from workers when navigating, r=loganfsmyth.
authorBrian Hackett <bhackett1024@gmail.com>
Mon, 25 Mar 2019 07:37:21 -0600
changeset 465952 69a4cc3f97e8252069ac6bf6655757b6edfecea6
parent 465919 7ed792328e9fc95b95fbdcc879f5c0562296004e
child 465953 1e5191f8b8b5545a54e7d49781c83510365618b9
push id35756
push usercbrindusan@mozilla.com
push dateTue, 26 Mar 2019 00:26:40 +0000
treeherdermozilla-central@55261bc2e465 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersloganfsmyth
bugs1537657
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1537657 - Detach from workers when navigating, r=loganfsmyth.
devtools/client/debugger/new/src/actions/navigation.js
devtools/client/debugger/new/src/actions/tests/navigation.spec.js
devtools/client/debugger/new/src/client/firefox/commands.js
--- a/devtools/client/debugger/new/src/actions/navigation.js
+++ b/devtools/client/debugger/new/src/actions/navigation.js
@@ -36,16 +36,17 @@ export function willNavigate(event: Obje
   return function({ dispatch, getState, client, sourceMaps }: ThunkArgs) {
     sourceMaps.clearSourceMaps();
     clearWasmStates();
     clearDocuments();
     clearSymbols();
     clearASTs();
     clearScopes();
     clearSources();
+    client.detachWorkers();
     dispatch(navigate(event.url));
   };
 }
 
 export function navigate(url: string) {
   return async function({ dispatch, getState }: ThunkArgs) {
     sourceQueue.clear();
     const thread = getMainThread(getState());
--- a/devtools/client/debugger/new/src/actions/tests/navigation.spec.js
+++ b/devtools/client/debugger/new/src/actions/tests/navigation.spec.js
@@ -22,17 +22,18 @@ const {
   getFileSearchResults
 } = selectors;
 
 const threadClient = {
   sourceContents: async () => ({
     source: "function foo1() {\n  const foo = 5; return foo;\n}",
     contentType: "text/javascript"
   }),
-  getBreakpointPositions: async () => ({})
+  getBreakpointPositions: async () => ({}),
+  detachWorkers: () => {}
 };
 
 describe("navigation", () => {
   it("connect sets the debuggeeUrl", async () => {
     const { dispatch, getState } = createStore({
       fetchWorkers: () => Promise.resolve([]),
       getMainThread: () => "FakeThread"
     });
@@ -62,37 +63,37 @@ describe("navigation", () => {
 
     results = getTextSearchResults(getState());
     expect(results).toHaveLength(0);
     expect(getTextSearchQuery(getState())).toEqual("");
     expect(getTextSearchStatus(getState())).toEqual("INITIAL");
   });
 
   it("navigation removes activeSearch 'project' value", async () => {
-    const { dispatch, getState } = createStore();
+    const { dispatch, getState } = createStore(threadClient);
     dispatch(actions.setActiveSearch("project"));
     expect(getActiveSearch(getState())).toBe("project");
 
     await dispatch(actions.willNavigate("will-navigate"));
     expect(getActiveSearch(getState())).toBe(null);
   });
 
   it("navigation clears the file-search query", async () => {
-    const { dispatch, getState } = createStore();
+    const { dispatch, getState } = createStore(threadClient);
 
     dispatch(actions.setFileSearchQuery("foobar"));
     expect(getFileSearchQuery(getState())).toBe("foobar");
 
     await dispatch(actions.willNavigate("will-navigate"));
 
     expect(getFileSearchQuery(getState())).toBe("");
   });
 
   it("navigation clears the file-search results", async () => {
-    const { dispatch, getState } = createStore();
+    const { dispatch, getState } = createStore(threadClient);
 
     const searchResults = [{ line: 1, ch: 3 }, { line: 3, ch: 2 }];
     dispatch(actions.updateSearchResults(2, 3, searchResults));
     expect(getFileSearchResults(getState())).toEqual({
       count: 2,
       index: 2,
       matchIndex: 1,
       matches: searchResults
@@ -104,16 +105,16 @@ describe("navigation", () => {
       count: 0,
       index: -1,
       matchIndex: -1,
       matches: []
     });
   });
 
   it("navigation removes activeSearch 'file' value", async () => {
-    const { dispatch, getState } = createStore();
+    const { dispatch, getState } = createStore(threadClient);
     dispatch(actions.setActiveSearch("file"));
     expect(getActiveSearch(getState())).toBe("file");
 
     await dispatch(actions.willNavigate("will-navigate"));
     expect(getActiveSearch(getState())).toBe(null);
   });
 });
--- a/devtools/client/debugger/new/src/client/firefox/commands.js
+++ b/devtools/client/debugger/new/src/client/firefox/commands.js
@@ -182,16 +182,22 @@ function locationKey(location: Breakpoin
   const sourceId = location.sourceId || "";
   return `${(sourceUrl: any)}:${sourceId}:${line}:${(column: any)}`;
 }
 
 function waitForWorkers(shouldWait: boolean) {
   shouldWaitForWorkers = shouldWait;
 }
 
+function detachWorkers() {
+  for (const thread of listWorkerThreadClients()) {
+    thread.detach();
+  }
+}
+
 function maybeGenerateLogGroupId(options) {
   if (options.logValue && tabTarget.traits && tabTarget.traits.canRewind) {
     return { ...options, logGroupId: `logGroup-${Math.random()}` };
   }
   return options;
 }
 
 function maybeClearLogpoint(location: BreakpointLocation) {
@@ -480,12 +486,13 @@ const clientCommands = {
   pauseOnExceptions,
   fetchSources,
   registerSourceActor,
   fetchWorkers,
   getMainThread,
   sendPacket,
   setSkipPausing,
   setEventListenerBreakpoints,
-  waitForWorkers
+  waitForWorkers,
+  detachWorkers
 };
 
 export { setupCommands, clientCommands };