Bug 1686950 - [devtools] RDM should stop watching resources and targets after performing cleanup r=nchevobbe

Depends on D103325

When we stop watching for resources, if there are no other watchers currently in activity, we will unregister the JSWindowActors, with following stack:
```
unregisterJSWindowActor@resource://devtools/server/actors/watcher/WatcherRegistry.jsm:344:17
maybeUnregisteringJSWindowActor@resource://devtools/server/actors/watcher/WatcherRegistry.jsm:280:7
unwatchTargets@resource://devtools/server/actors/watcher.js:199:21
handler@resource://devtools/shared/protocol/Actor.js:172:37
onPacket@resource://devtools/server/devtools-server-connection.js:379:58
send/<@resource://devtools/shared/transport/local-transport.js:68:25
exports.makeInfallible/<@resource://devtools/shared/ThreadSafeDevToolsUtils.js:103:22
DevToolsUtils.executeSoon*exports.executeSoon@resource://devtools/shared/DevToolsUtils.js:54:21
send@resource://devtools/shared/transport/local-transport.js:56:21
send@resource://devtools/shared/protocol/Front.js:272:30
generateRequestMethods/</frontProto[name]@resource://devtools/shared/protocol/Front/FrontClassWithSpec.js:42:14
stopListening@resource://devtools/shared/resources/target-list.js:363:29
destroy@resource://devtools/shared/resources/target-list.js:612:10
```

This will lead to destroy all the currently created JSWindowActors, which will also destroy the corresponding target actors.
However RDM will still try to perform some cleanups on the current target after destroying the target-list. These calls will fail as soon as RDM uses a JSWindowActor based target.
This will only start happening in Bug 1644397, but then it will make the test browser_tab_remoteness_change_fission_switch_target.js fail on shutdown.

Differential Revision: https://phabricator.services.mozilla.com/D103326
This commit is contained in:
Julian Descottes 2021-02-02 19:08:22 +00:00
Родитель 20122a5d0a
Коммит 36fd4f01e4
1 изменённых файлов: 16 добавлений и 12 удалений

Просмотреть файл

@ -295,18 +295,6 @@ class ResponsiveUI {
// Resseting the throtting needs to be done before the
// network events watching is stopped.
await this.updateNetworkThrottling();
this.targetList.unwatchTargets(
[this.targetList.TYPES.FRAME],
this.onTargetAvailable
);
this.resourceWatcher.unwatchResources(
[this.resourceWatcher.TYPES.NETWORK_EVENT],
{ onAvailable: this.onNetworkResourceAvailable }
);
this.targetList.destroy();
}
this.tab.removeEventListener("TabClose", this);
@ -344,6 +332,22 @@ class ResponsiveUI {
if (reloadNeeded && currentTarget) {
await currentTarget.reload();
}
// Unwatch targets & resources as the last step. If we are not waching for
// any resource & target anymore, the JSWindowActors will be unregistered
// which will trigger an early destruction of the RDM target, before we
// could finalize the cleanup.
this.targetList.unwatchTargets(
[this.targetList.TYPES.FRAME],
this.onTargetAvailable
);
this.resourceWatcher.unwatchResources(
[this.resourceWatcher.TYPES.NETWORK_EVENT],
{ onAvailable: this.onNetworkResourceAvailable }
);
this.targetList.destroy();
}
// Show the browser UI now.