Closed Bug 1663896 Opened 4 years ago Closed 4 years ago

Simultaneous calls to watchResources lead to missing resources from targets

Categories

(DevTools :: Framework, task, P3)

task

Tracking

(firefox82 fixed)

RESOLVED FIXED
82 Branch
Tracking Status
firefox82 --- fixed

People

(Reporter: jdescottes, Assigned: jdescottes)

Details

Attachments

(2 files)

If you perform two calls to resourceWatcher.watchResources "simultaneously", the second call will not be able to retrieve existing resources coming from targets.

This comes from the implementation of _watchAllTargets:

  async _watchAllTargets() {
    if (this._isWatchingTargets) {
      return;
    }
    this._isWatchingTargets = true;
    await this.targetList.watchTargets(
      this.targetList.ALL_TYPES,
      this._onTargetAvailable,
      this._onTargetDestroyed
    );
  }

https://searchfox.org/mozilla-central/rev/b2716c233e9b4398fc5923cbe150e7f83c7c6c5b/devtools/shared/resources/resource-watcher.js#173-183

Based on this, the first call to watchResources will flip _isWatchingTargets to true, and the second call will bypass it. It means the second call will jump straight to the "startListening" step, before the "resource-available-form" listeners have been added on the existing targets.

Pushed by jdescottes@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b0b56040bb4e
Always wait for _watchAllTargets to resolve in DevTools ResourceWatcher r=ochameau
https://hg.mozilla.org/integration/autoland/rev/1ed7fee9c145
Remove async for TargetList::unwatchTargets and update call sites r=ochameau
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 82 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: