Closed Bug 1638007 Opened 6 months ago Closed 5 months ago

Optimize webRequest to apply tabId filtering before URL matching

Categories

(WebExtensions :: Request Handling, enhancement, P1)

enhancement

Tracking

(firefox78 fixed)

RESOLVED FIXED
mozilla78
Tracking Status
firefox78 --- fixed

People

(Reporter: robwu, Assigned: robwu)

References

Details

Attachments

(2 files)

In bug 1630994, a performance issue was described, that is caused by an add-on using multiple webRequest listeners, a tab-specific listener for every tab.

Since a tabId check is typically less expensive than the more complicated URL pattern checking, the browser should check the tabId in the request filter before matching URL patterns. This is currently not happening, because the event handling currently happens in two separate layers, WebRequest.jsm and ext-webRequest.js for historical reasons. The former used to have multiple consumers (external addons), but by now this module is only used by ext-webRequest.js and some unit tests.

To resolve this bug, tabId handling should move from ext-webRequest.jsm to WebRequest.jsm.

In bug 1580766, work is being done that could allow us to determine the tabId independent of the rest of the extension framework. Once that bug is fixed, we could add tabId in WebRequest.jsm.

This bug could also be resolved without bug 1580766 by importing the tabTracker in WebRequest.jsm, like we do for the proxy API in https://searchfox.org/mozilla-central/rev/9f074fab9bf905fad62e7cc32faf121195f4ba46/toolkit/components/extensions/ProxyChannelFilter.jsm#31-33

Blocks: 1630994
Assignee: nobody → rob
Severity: -- → S3
Status: NEW → ASSIGNED
Priority: -- → P1
See Also: → 1641269

This test doesn't need to use WebRequest.jsm, so remove the dependency.

See Also: → 1641638
Pushed by rob@robwu.nl:
https://hg.mozilla.org/integration/autoland/rev/0cb9e7cd5267
Replace WebRequest.jsm with ^headers^ in browser_default_image_filename_redirect.js r=mixedpuppy
Pushed by rob@robwu.nl:
https://hg.mozilla.org/integration/autoland/rev/434343de944e
Check windowId/tabId before urls r=mixedpuppy
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla78

Backed out changeset 434343de944e (bug 1638007) for Mochitest failures in toolkit/components/extensions/test/mochitest/test_ext_activityLog.html. CLOSED TREE

Log:
https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=304298600&repo=autoland&lineNumber=12277

Push with failures:
https://treeherder.mozilla.org/#/jobs?repo=autoland&group_state=expanded&revision=434343de944ebcdf20decc4de662f1822ce16ebe

Push was busted becuse of gecko decision task bustage.

Backout:
https://hg.mozilla.org/integration/autoland/rev/8e79edbbce00f5ea1326017179de917f7137c12f

Flags: needinfo?(rob)

That test didn't appear in ./mach try auto and it didn't run locally because it was skipped on my platform.

I fixed the issue and am going to reland it.

Flags: needinfo?(rob)
Pushed by rob@robwu.nl:
https://hg.mozilla.org/integration/autoland/rev/009021c1beb7
Check windowId/tabId before urls r=mixedpuppy
You need to log in before you can comment on or make changes to this bug.