Closed Bug 1710674 Opened 3 years ago Closed 3 years ago

target-mixin resource cache mechanism is misbehaving

Categories

(DevTools :: Framework, defect)

defect

Tracking

(Fission Milestone:M7a, firefox90 fixed)

RESOLVED FIXED
90 Branch
Fission Milestone M7a
Tracking Status
firefox90 --- fixed

People

(Reporter: nchevobbe, Assigned: nchevobbe)

References

Details

(Whiteboard: dt-fission-m3-mvp)

Attachments

(1 file)

While investigating test failures for https://phabricator.services.mozilla.com/D78862 , I discovered a couple things that were wrong with the target-mixin resource cache:

  1. in https://searchfox.org/mozilla-central/source/devtools/client/fronts/targets/target-mixin.js#75 , we are not removing the listeners we set before, as we're creating new functions when binding, not retrieving the one we created in the constructor
  2. even if we'd remove it properly, we're only entering the if block if some resources were put in the cache. It could happen that it's not the case, and that would cause unwanted behavior later on.
    Here's a scenario we can have:
  • a target is created, which sets up the resource-available-form event listener in target-mixin
  • targetFront.on("resource-available-form", ...) is then called from the resourceCommand
  • since there were no existing resources, the event listeners is not removed
  • later, some resources are sent, and are put in the target-mixin cache
  • resourceCommand.unwatching is called, and then resourceCommand.watch again
  • this causes another targetFront.on("resource-available-form", ...)
  • now we do have resources in the target-mixin cache, which means we're removing the listener from target-mixin, but also that we are calling resourceCommand.onResourceAvailable with the resources that were in the cache

The event listeners that were set in the constructor were not
actually removed in the on method, as we weren't using the
proper function reference.
Furthermore, the event listeners were removed only if some
resources were put in the cache, which could lead to some
buggy behavior when watching/unwatching multiple times.

Depends on D114926

Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Whiteboard: dt-fission-m3-mvp
Blocks: 1644360
Fission Milestone: --- → M7a
Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/bece73e88772
[devtools] Fix target-mixin resource cache mechanism. r=ochameau,bomsy.
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: