Closed Bug 1343677 Opened 8 years ago Closed 8 years ago

Consider adding asserts in nsCSSProps::IsEnabled that we've received the prefs from the parent process

Categories

(Core :: CSS Parsing and Computation, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox54 --- wontfix
firefox55 --- fixed

People

(Reporter: bzbarsky, Assigned: bzbarsky)

Details

Attachments

(3 files)

We want to catch it if we try to parse some pref-dependent CSS before we know our pref values. Is it possible to detect, in a debug build, whether we've received the initial pref data in the content process?
Flags: needinfo?(wmccloskey)
To be clear, the idea here is to catch cases when prefs we did not add in dom/ipc/ContentPrefs.cpp are accessed too early from the style system.
OK. So we could add a Preferences::GetInitPhase(). So I guess we can ContentPrefs::GetContentPrefs, check whether our pref is in the list, and if not assert that the phase is END_ALL_PREFS or so?
Yeah, I think that should work. I don't really understand the UA stylesheet issue though. Is there a way that we could work around this so that we don't have to send these prefs on the command line? Could we initialize the UA stylesheet stuff later?
> Could we initialize the UA stylesheet stuff later? It's really not clear to me that we don't already do that. We initialize it the first time we create a document that needs styling. That _ought_ to be pretty late! I just don't know for sure. Once we have asserts for this stuff, we should try removing it from the list and seeing whether they trigger.
I guess there's also the question of how to make this play with stylo and its pref setup.
Ah, I guess stylo just calls nsCSSProps::IsEnabled.
So I tried doing the obvious thing and asserting that we're at the END_ALL_PREFS phase when IsEnabled() is called. This fails to start up, and it has nothing to do with content processes, even. In the chrome process, the "addons-startup" notification is dispatched, WebCompatReporter.jsm runs, gets the stylesheet service, and does preloadSheet, passing "chrome://webcompat-reporter/skin/lightbulb.css" as the URI. This is all happening quite early, before we've loaded prefs even in the parent process, I guess. The good news is presumably that it doesn't use any pref-controlled properties in that sheet. The bad news is that this makes it a bit more complicated to figure out what the right thing to assert is.
Hmm. I guess we never actually change the pref phase in the parent process. So maybe I need to restrict the assert to the content process...
MozReview-Commit-ID: JtHhLuFDu2d
Attachment #8847929 - Flags: review?(wmccloskey)
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
This ensures that we don't read incorrect values out of the gPropertyEnabled array simply because we haven't gotten preference values from the parent process yet. MozReview-Commit-ID: 59AgN3ecXQl
Attachment #8847930 - Flags: review?(wmccloskey)
Attachment #8847930 - Flags: review?(dholbert)
We're now asserting that we never check these before the END_ALL_PREFS phase, which means they don't need to be sent to the content process synchronously. MozReview-Commit-ID: 4BGbvVCjDWz
Attachment #8847931 - Flags: review?(wmccloskey)
Attachment #8847931 - Flags: review?(dholbert)
Comment on attachment 8847930 [details] [diff] [review] part 2. Assert in nsCSSprops::IsEnabled that we have received all preferences Review of attachment 8847930 [details] [diff] [review]: ----------------------------------------------------------------- This seems fine to me. r=me
Attachment #8847930 - Flags: review?(dholbert) → review+
Comment on attachment 8847931 [details] [diff] [review] part 3. Remove all the CSS bits from the ContentPrefs whitelist Review of attachment 8847931 [details] [diff] [review]: ----------------------------------------------------------------- This seems fine to me, if billm's OK with it & if the assertion doesn't fire.
Attachment #8847931 - Flags: review?(dholbert) → review+
Attachment #8847929 - Flags: review?(wmccloskey) → review+
Comment on attachment 8847930 [details] [diff] [review] part 2. Assert in nsCSSprops::IsEnabled that we have received all preferences Review of attachment 8847930 [details] [diff] [review]: ----------------------------------------------------------------- ::: layout/style/nsCSSProps.h @@ +635,5 @@ > "out of range"); > + // We don't have useful pref init phases in the parent process. But in the > + // child process, assert that we're not trying to parse stylesheets before > + // we've gotten all our prefs. > + MOZ_ASSERT(XRE_IsParentProcess() || MOZ_ASSERT_IF(XRE_IsContentProcess(), ...) is a little nicer IMO, but it looks like it doesn't allow the string to be passed in :-(. I guess it's fine as-is.
Attachment #8847930 - Flags: review?(wmccloskey) → review+
Comment on attachment 8847931 [details] [diff] [review] part 3. Remove all the CSS bits from the ContentPrefs whitelist Review of attachment 8847931 [details] [diff] [review]: ----------------------------------------------------------------- Thanks for doing this Boris.
Attachment #8847931 - Flags: review?(wmccloskey) → review+
Pushed by bzbarsky@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/55ee07a916b8 part 1. Add a way to get the current preferences init phase in debug builds. r=billm https://hg.mozilla.org/integration/mozilla-inbound/rev/d6b773c15593 part 2. Assert in nsCSSprops::IsEnabled that we have received all preferences. r=dholbert,billm https://hg.mozilla.org/integration/mozilla-inbound/rev/008b180abd4a part 3. Remove all the CSS bits from the ContentPrefs whitelist. r=billm,dholbert
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: