Re: Using preferences off the main thread now asserts
On 3/6/2014 4:05 PM, Benoit Girard wrote: Thanks for doing this. However I feel like our options for code that need preferences off the main thread are a bit poor. Yes. This is mostly intentional, because it's unusual to actually have user preferences affect threaded code behavior in ways that don't require knowledge of and cooperation from the main thread. What is the use case where you need this? The first option is to send an IPC message to the main thread but that has very poor performance, requires a lot of boilerplate code and either an sync message or async+restructuring the control flow. The second option is to read the preferences on startup and have them as read-only shared globals like gfxPrefs: http://mxr.mozilla.org/mozilla-central/source/gfx/thebes/gfxPrefs.h#106 The third option is to use pref observers and a lock to save the state of a pref in a protected variable. For cases where you actually want to honor runtime changes, this makes the most sense. --BDS ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Using preferences off the main thread now asserts
On Thursday 2014-03-06 19:52 -0800, Nicholas Nethercote wrote: > On Thu, Mar 6, 2014 at 8:20 AM, Kyle Huey wrote: > > It's taken over 3 years, but Bug 619487 is now fixed, and the > > preferences service will assert (fatally) if you try to use it off the > > main thread. > > Out of curiosity, what's the benefit of this? Is it just a correctness > issue? The bug didn't have much detail. It's an issue of not crashing when trying to manipulate the same hashtable from two different threads at the same time without any sort of locking. -David -- 𝄞 L. David Baron http://dbaron.org/ 𝄂 𝄢 Mozilla https://www.mozilla.org/ 𝄂 Before I built a wall I'd ask to know What I was walling in or walling out, And to whom I was like to give offense. - Robert Frost, Mending Wall (1914) signature.asc Description: Digital signature ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Using preferences off the main thread now asserts
On Thu, Mar 6, 2014 at 8:20 AM, Kyle Huey wrote: > It's taken over 3 years, but Bug 619487 is now fixed, and the > preferences service will assert (fatally) if you try to use it off the > main thread. Out of curiosity, what's the benefit of this? Is it just a correctness issue? The bug didn't have much detail. Nick ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Using preferences off the main thread now asserts
Thanks for doing this. However I feel like our options for code that need preferences off the main thread are a bit poor. The first option is to send an IPC message to the main thread but that has very poor performance, requires a lot of boilerplate code and either an sync message or async+restructuring the control flow. The second option is to read the preferences on startup and have them as read-only shared globals like gfxPrefs: http://mxr.mozilla.org/mozilla-central/source/gfx/thebes/gfxPrefs.h#106 Ideally I'd like to only read in the preference when/if I need to access it, particularly as we have increasingly more code living off the main thread. On Thu, Mar 6, 2014 at 11:20 AM, Kyle Huey wrote: > It's taken over 3 years, but Bug 619487 is now fixed, and the > preferences service will assert (fatally) if you try to use it off the > main thread. This is currently disabled on b2g while I track down the > last misuses of the pref service in b2g-specific code. > > After the next train leaves I plan to upgrade these to release mode > assertions so we can start catching addons that misuse the pref > service. > > - Kyle > ___ > dev-platform mailing list > dev-platform@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-platform > ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Using preferences off the main thread now asserts
Huzzah! Well done Kyle. On Mar 6, 2014 8:20 AM, "Kyle Huey" wrote: > It's taken over 3 years, but Bug 619487 is now fixed, and the > preferences service will assert (fatally) if you try to use it off the > main thread. This is currently disabled on b2g while I track down the > last misuses of the pref service in b2g-specific code. > > After the next train leaves I plan to upgrade these to release mode > assertions so we can start catching addons that misuse the pref > service. > > - Kyle > ___ > dev-platform mailing list > dev-platform@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-platform > ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform