Closed Bug 1823390 Opened 2 years ago Closed 2 years ago

[DNR] Replace extension.readJSON with fetch for reading static rules JSON files

Categories

(WebExtensions :: Request Handling, task, P1)

task

Tracking

(firefox113 fixed)

RESOLVED FIXED
113 Branch
Tracking Status
firefox113 --- fixed

People

(Reporter: rpl, Assigned: rpl)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [addons-jira])

Attachments

(2 files)

DNRStore's #getManifestStaticRulesets method is currently calling extension.readJSON to load the JSON files for the DNR static rulesets enabled, but internally extension.readJSON calls String.prototype.replace with a regular expression to remove inline comments from the JSON files data retrieved and that have a noticeable impact due to the size that the DNR rulesets size may likely have (especially compared to the usual size of manifest.json and locale files may have).

Given that Chrome doesn't support inline comments in DNR rulesets, we can the call to extension.readJSON with fetch, which wouldn't allow inline comments in the rulesets JSON files but it would have a smaller impact due to not going through a call to String.prototype.replace and through the js RegExp evaluations.

DNRStore's #getManifestStaticRulesets method is currently using extension.readJSON to load the JSON files
for the DNR static rulesets enabled, but internally extension.readJSON calls String.prototype.replace with
a regular expression to remove inline comments from the JSON files data retrieved and that have a noticebeable
impact due to the size that the DNR rulesets size may likely have (especially compared to the usual size of
manifest.json and locale files may have).

Given that Chrome doesn't support inline comments in DNR rulesets, we can consider replacing the call to
extension.readJSON with fetch, which wouldn't allow inline comments in the rulesets JSON files but
it would have a smaller impact due to not going through a call to String.prototype.replace and through
the js RegExp evaluations.

Alternatively we may consider keeping the call to extension.readJSON but tweak it to make sure we opt
out from the call to String.prototype.replace for this particular call (by also tweaking readJSON
method to allow that).

Assignee: nobody → lgreco
Status: NEW → ASSIGNED
Whiteboard: [addons-jira]
Pushed by luca.greco@alcacoop.it:
https://hg.mozilla.org/integration/autoland/rev/f8ed3816d6f1
Fix typo in assertion message in head_dnr.js. r=robwu
https://hg.mozilla.org/integration/autoland/rev/754403851a9d
Replace extension.readJSON with fetch to reduce perf impact of loading the DNR ruleset. r=robwu
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 113 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: