Closed Bug 1353174 Opened 7 years ago Closed 7 years ago

Turn ContentObservers.jsm into a process script

Categories

(Firefox :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 55
Tracking Status
firefox55 --- fixed

People

(Reporter: mccr8, Assigned: mccr8)

References

Details

Attachments

(2 files)

The comment at the top of ContentObserver.jsm says "This module is for small observers that we want to register once per content process, usually in order to forward content-based observer service notifications to the chrome process through message passing. Using a JSM avoids having them in content.js and thereby registering N observers for N open tabs, which is bad for perf."

If we turn this into a process script (maybe loaded from nsBrowserGlue.js like pdf.js does) then we can get the benefits of running only once per process without the overhead of one jsm per content process.
Blocks: 1352522
Hmm, that's not a good diff. I'll see if I can get it to actually show the move. Somehow.Hmm, so that git
Comment on attachment 8854521 [details]
Bug 1353174, part 1 - Turn ContentObservers.jsm into a process script.

https://reviewboard.mozilla.org/r/126480/#review129010

::: browser/components/nsBrowserGlue.js:862
(Diff revision 1)
> +
> +    Services.ppmm.loadProcessScript("resource:///modules/ContentObservers.js", true);

I think this is too late, and I'm not sure why pdfjs (higher up in this method) waits this long, either. This is firing after the delayed startup of the first browser window finishes, but content.js is added to the content browsers here:

https://dxr.mozilla.org/mozilla-central/source/browser/base/content/browser.js#1154-1158

which is significantly earlier (onLoad rather than delayed startup).
Attachment #8854521 - Flags: review?(gijskruitbosch+bugs)
Attachment #8854593 - Flags: review?(gijskruitbosch+bugs)
Comment on attachment 8854593 [details]
Bug 1353174, part 2 - Fix up ContentObservers.js.

https://reviewboard.mozilla.org/r/126550/#review129088
Attachment #8854593 - Flags: review?(gijskruitbosch+bugs) → review+
Comment on attachment 8854521 [details]
Bug 1353174, part 1 - Turn ContentObservers.jsm into a process script.

https://reviewboard.mozilla.org/r/126480/#review129090
Attachment #8854521 - Flags: review?(gijskruitbosch+bugs) → review+
I didn't realize that browser.js is run once per browser window, though I suppose that makes sense.

By putting this code in MainProcessSingleton.js it seems to load it once per process, as expected, and it loads before browser.js runs, so hopefully that is early enough, but not too early.
Pushed by amccreight@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/05ba30ffa434
part 1 - Turn ContentObservers.jsm into a process script. r=Gijs
https://hg.mozilla.org/integration/autoland/rev/fe34ea100aa3
part 2 - Fix up ContentObservers.js. r=Gijs
I would have expected this to run into bug 1352982. I don't really understand why it didn't. Florian, do you?
Flags: needinfo?(florian)
(In reply to :Gijs from comment #12)
> I would have expected this to run into bug 1352982. I don't really
> understand why it didn't. Florian, do you?

I don't really understand either. Is it possible that the browser_all_files_referenced.js test has not been run in any non-clobber os x build since this patch was pushed to autoland?
Flags: needinfo?(florian)
https://hg.mozilla.org/mozilla-central/rev/05ba30ffa434
https://hg.mozilla.org/mozilla-central/rev/fe34ea100aa3
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 55
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: