Open
Bug 791881
Opened 13 years ago
Updated 3 years ago
SpecialPowers.setPref and Services.prefs.getPref aren't in sync on child process
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
NEW
People
(Reporter: gwagner, Unassigned)
Details
Attachments
(1 file)
|
1.64 KB,
patch
|
Details | Diff | Splinter Review |
We see some races using following code in a child process (mochitest on otoro):
SpecialPowers.setBoolPref("xxx", false);
SpecialPowers.getBoolPref("xxx");
Services.prefs.getBoolPref("xxx");
According to bent, SpecialPowers uses a sync approach and Services an async approach.
| Reporter | ||
Comment 1•13 years ago
|
||
Assignee: nobody → anygregor
(In reply to Gregor Wagner [:gwagner] from comment #0)
> According to bent, SpecialPowers uses a sync approach and Services an async
> approach.
Not quite... SpecialPowers sends sync messages to the parent, but then the message that the parent sends to the child to update the child's pref set is an async message. Due to the way IPDL messages work that async message won't be seen until after the child has returned to the event loop.
Isn't this why pushPrefEnv exists?
Not as far as I can tell. pushPrefEnv() just pushes prefs so that they can be popped off automatically at the end of the test, right? There is some fancy setTimeout() madness there to try to wait for all of the parent process changes to trickle down, so maybe you're right?
However, it's really not obvious that setBoolPref() is "wrong" and pushPrefEnv() is "right" here. We should either fix setBoolPref() to do the change synchronously or remove the sync API here entirely.
| Reporter | ||
Comment 5•13 years ago
|
||
tryserver is not happy: https://tbpl.mozilla.org/?tree=Try&rev=cb307323bc79
Comment 6•13 years ago
|
||
The origin of pushPrefEnv came from my investigations that revealed this problem. pushPrefEnv takes a callback that executes once the child process receives a notification that the pref is updated, making it the correct thing to use. My patch that made setFooPref spin the event loop until the same thing happened was denied.
Tests aren't allowed to use set*Pref() directly.
| Reporter | ||
Comment 8•13 years ago
|
||
(In reply to Chris Jones [:cjones] [:warhammer] from comment #7)
> Tests aren't allowed to use set*Pref() directly.
Hm I guess I don't understand. How should we use it instead?
From MDN: SpecialPowers is a set of APIs available to Mochitest tests.
If we can't use SpecialPowers.set*Pref we have to rewrite many tests.
(In reply to Chris Jones [:cjones] [:warhammer] from comment #7)
> Tests aren't allowed to use set*Pref() directly.
http://mxr.mozilla.org/mozilla-central/search?string=SpecialPowers\.set.*Pref®exp=1&find=&findi=&filter=^[^\0]*%24&hitlimit=&tree=mozilla-central
(In reply to Gregor Wagner [:gwagner] from comment #8)
> (In reply to Chris Jones [:cjones] [:warhammer] from comment #7)
> > Tests aren't allowed to use set*Pref() directly.
>
> Hm I guess I don't understand. How should we use it instead?
pushPrefEnv().
> From MDN: SpecialPowers is a set of APIs available to Mochitest tests.
> If we can't use SpecialPowers.set*Pref we have to rewrite many tests.
The plan was to remove all those and then remove set*().
Comment 11•12 years ago
|
||
I've filed bug 1056851 for conversion to SpecialPowers.pushPrefEnv.
I guess this bug could be used for that, but I think it would be better to have a new bug for it.
But it would mean this bug can closed. Is it ok to close this bug?
| Assignee | ||
Updated•7 years ago
|
Component: DOM → DOM: Core & HTML
Comment 12•4 years ago
|
||
The bug assignee is inactive on Bugzilla, so the assignee is being reset.
Assignee: anygregor → nobody
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•