Closed Bug 814517 Opened 12 years ago Closed 9 years ago

[meta] Many prefs are read before Preferences::ResetAndReadUserPrefs() is called

Categories

(Core :: Preferences: Backend, defect)

22 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: kats, Unassigned)

References

Details

(Keywords: meta)

Attachments

(1 file, 1 obsolete file)

I'm not sure how much of a problem this is but filing anyway to discuss and figure it out. While testing bug 807998 I discovered that the memory.free_dirty_pages pref added in bug 805855 is read before ResetAndReadUserPrefs is called. As a result, the value obtained is always the default value of the pref, and setting it manually via about:config has no effect. I then set a couple of breakpoints and dumped out all the keys passed to pref_HashTableLookup before ResetAndReadUserPrefs is called, to see if there were other prefs in the same situation. Turns out there are a lot (214 unique prefs, 257 calls to pref_HashTableLookup). I haven't investigated if any of these are read again after ResetAndReadUserPrefs is called, or if anybody cares that the initial value read may not take into account what the user does in about:config, but in the case of memory.free_dirty_pages it seems to be a bug.
The issue introduced in bug 805855 should be fixed because the preference is being randomized during testing (see bug 805855 comment 98) and so we need to be able to read a different value from the user settings. The attached patch should fix the problem by mimicking the behavior of the rest of the AvailableMemoryTracker code regarding this kind of changes. I'm asking Justin to review it because he was the one who reviewed the original patch.
Attachment #687162 - Flags: review?(justin.lebar+bug)
Comment on attachment 687162 [details] [diff] [review] Properly react to changes to the 'memory.free_dirty_pages' preference > +#define FREE_DIRTY_PAGES_PREF "memory.free_dirty_pages" I'm not a big fan of this sort of one-time define (even though we use it somewhat frequently in our code), but r=me either way.
Attachment #687162 - Flags: review?(justin.lebar+bug) → review+
You may want to update the bug summary, if this patch is all you intend to fix in this bug.
(In reply to Justin Lebar [:jlebar] from comment #2) > > +#define FREE_DIRTY_PAGES_PREF "memory.free_dirty_pages" > > I'm not a big fan of this sort of one-time define (even though we use it > somewhat frequently in our code), but r=me either way. Actually it's a leftover of my first try where I used it in a couple more places. It's useless, I'll get rid of it. > You may want to update the bug summary, if this patch is all you intend to > fix in this bug. I'll have a look at the other instances of this problem, it shouldn't be too hard to find all the prefs consumers that are starting before ResetAndReadUserPrefs(). There's no rush in closing this after all.
> There's no rush in closing this after all. Well, yes and no. We like to close bugs after a fix lands (although we don't always succeed in this respect). If you're going to try to fix other instances of this problem, but not fix them in one fell swoop, the canonical way to do it is to have a metabug ("Many prefs are read before Preferences::ResetAndReadUserPrefs() is called") and then create a bug which blocks the metabug for each change you're going to land as a unit.
(In reply to Justin Lebar [:jlebar] from comment #5) > If you're going to try to fix other instances of this problem, but not fix > them in one fell swoop, the canonical way to do it is to have a metabug > ("Many prefs are read before Preferences::ResetAndReadUserPrefs() is > called") and then create a bug which blocks the metabug for each change > you're going to land as a unit. OK, I'll try to get a feeling of how many places are affected by this; if it's just a couple then I'll try to quickly fix them in this bug and be done with it. If it's more I'll open individual bugs, make this one a meta-bug and move my patch into the appropriate one.
I finally had the time to give a good look at this one by back-tracking from every pref_HashTableLookup() call that happens before Preferences::ResetAndReadUserPrefs(). I've found at least 7 preferences of which I'm almost certain that they're not being handled properly (including the one I introduced) and another ~20 potential candidates that I need to investigate further. Later on today I'll turn this into a meta-bug and then file separate bugs for every component I will be able to confirm is not handling its prefs correctly; I'll move the existing patch there too.
Depends on: 850607
Comment on attachment 687162 [details] [diff] [review] Properly react to changes to the 'memory.free_dirty_pages' preference Obsoleting as I've moved the patch to bug 850607.
Attachment #687162 - Attachment is obsolete: true
Keywords: meta
OS: Android → All
Hardware: ARM → All
Summary: Many prefs are read before Preferences::ResetAndReadUserPrefs() is called → [meta] Many prefs are read before Preferences::ResetAndReadUserPrefs() is called
Version: 19 Branch → 22 Branch
Depends on: 850637
Depends on: 850664
Depends on: 850688
Depends on: 850697
I should have filed all the instances of components reading prefs too early I could reasonably confirm even though some of them might be deliberate choices. For those that are deliberate choices I'd still like to add a comment in the relevant piece of code to clarify that only defaults are taken into account. There's one last instance that I haven't filed a bug for and it's jsloader.reuseGlobal being loaded in mozJSComponentLoader::ReallyInit(). There the choice of ignoring a user-set value for that preference seems deliberate considering that the code contains an assertion to ensure that the value hasn't been flipped from true to false after one or more modules have already been loaded.
Just for kicks I added some logging to my local b2g build to see how much this is still happening. There's still a fair number of prefs being read before the user prefs are loaded - not sure how many of them are intentionally that way. Log attached.
Attachment #8580875 - Attachment mime type: text/x-vhdl → text/plain
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: