CFPreferences and Mountain Lion

  • Hi all,

    My preferences code strictly uses the CFPreferences api and has worked
    reliably since Tiger. On Mountain Lion Preview 4 (with the recent
    update), though, preferences writing has been erratic, sometimes my
    preferences are updated correctly, sometimes not. Are there any known
    issues with CFPreferences on Mountain Lion?

    I found this similar problem another developer is having:

    https://groups.google.com/forum/?fromgroups#!topic/munki-dev/fzp3SubBTJ0

    There is a statement there, "In 10.8 preferences are all cached by a
    preference daemon, and the point at which it reads from/writes to disk
    is not reliable..." Is that true? Is so, how can one be sure that
    preferences are updated at all? Is there any doc on the behavior of
    cfprefsd? The man page says basically nothing.

    Thanks,
    Michael Domino
  • On Jun 21, 2012, at 11:17 AM, Michael Domino wrote:

    > Hi all,
    >
    > My preferences code strictly uses the CFPreferences api and has worked reliably since Tiger. On Mountain Lion Preview 4 (with the recent update), though, preferences writing has been erratic, sometimes my preferences are updated correctly, sometimes not. Are there any known issues with CFPreferences on Mountain Lion?

    Mountain Lion is under NDA. You cannot talk about it here.

    --Kyle Sluder
  • On Jun 21, 2012, at 12:17 PM, Michael Domino wrote:

    > My preferences code strictly uses the CFPreferences api and has worked reliably since Tiger. On Mountain Lion Preview 4 (with the recent update), though, preferences writing has been erratic, sometimes my preferences are updated correctly, sometimes not. Are there any known issues with CFPreferences on Mountain Lion?

    My problems with prefs started with Lion, FYI...

    --
    Scott Ribe
    <scott_ribe...>
    http://www.elevated-dev.com/
    (303) 722-0567 voice
  • On Jun 21, 2012, at 11:33 AM, Scott Ribe wrote:

    > On Jun 21, 2012, at 12:17 PM, Michael Domino wrote:
    >
    >> My preferences code strictly uses the CFPreferences api and has worked reliably since Tiger. On Mountain Lion Preview 4 (with the recent update), though, preferences writing has been erratic, sometimes my preferences are updated correctly, sometimes not. Are there any known issues with CFPreferences on Mountain Lion?
    >
    > My problems with prefs started with Lion, FYI…

    I guess the question is, why do you care whether the preferences have been written to disk? As long as everyone is using the correct API to access preferences, it doesn't matter whether CFPreferences is caching them in memory before flushing them to disk. (Likewise, you shouldn't be storing user-critical data in preferences.)

    --Kyle Sluder
  • On Jun 21, 2012, at 12:39 PM, Kyle Sluder wrote:

    > I guess the question is, why do you care whether the preferences have been written to disk? As long as everyone is using the correct API to access preferences, it doesn't matter whether CFPreferences is caching them in memory before flushing them to disk.

    Because they do not always get flushed to disk; sometimes they disappear. Because it is completely random whether or not changes are visible to other applications that share them--despite their having been sync'd.

    --
    Scott Ribe
    <scott_ribe...>
    http://www.elevated-dev.com/
    (303) 722-0567 voice
  • Ditto for me, my prefs are sometimes not getting to disk ever, so I can't rely on seeing preferences set the way I left them. This only happens for me on 10.8, Lion does not exhibit this problem in my app.

    -----Original Message-----
    From: "Scott Ribe" <scott_ribe...>
    Sent: Thursday, June 21, 2012 2:44pm
    To: "Kyle Sluder" <kyle...>
    Cc: "Michael Domino" <michael.domino...>, <cocoa-dev...>
    Subject: Re: CFPreferences and Mountain Lion

    On Jun 21, 2012, at 12:39 PM, Kyle Sluder wrote:

    > I guess the question is, why do you care whether the preferences have been written to disk? As long as everyone is using the correct API to access preferences, it doesn't matter whether CFPreferences is caching them in memory before flushing them to disk.

    Because they do not always get flushed to disk; sometimes they disappear. Because it is completely random whether or not changes are visible to other applications that share them--despite their having been sync'd.

    --
    Scott Ribe
    <scott_ribe...>
    http://www.elevated-dev.com/
    (303) 722-0567 voice
  • Sharing preferences between applications is not something you can rely on in
    a sandboxed environment.  On 10.7, Preview and TextEdit are sandboxed so if
    you're seeing this behavior with them, that's why.  You can reasonably
    expect more applications to be sandboxed in the future.

    On 6/21/12 2:44 PM, "Scott Ribe" <scott_ribe...> thusly spake:

    > On Jun 21, 2012, at 12:39 PM, Kyle Sluder wrote:
    >
    >> I guess the question is, why do you care whether the preferences have been
    >> written to disk? As long as everyone is using the correct API to access
    >> preferences, it doesn't matter whether CFPreferences is caching them in
    >> memory before flushing them to disk.
    >
    > Because they do not always get flushed to disk; sometimes they disappear.
    > Because it is completely random whether or not changes are visible to other
    > applications that share them--despite their having been sync'd.

    Chad Hulbert
    Software Engineer
    Xerox Corporation
    800 Phillips Rd
    Webster, NY 14580

    p 585.427.3295  (8*707.3295)
  • On Jun 21, 2012, at 1:20 PM, <michael.domino...> wrote:

    >
    > Ditto for me, my prefs are sometimes not getting to disk ever, so I can't rely on seeing preferences set the way I left them. This only happens for me on 10.8, Lion does not exhibit this problem in my app.

    This topic should go on Apple's developer forums since Mountain Lion is currently covered by NDA (and bugs should be reported!).

    Preston
  • I'm not sandboxed, and the preferences I'm sharing are between my own apps. Also it variously works then doesn't work for a while on the same machine, same OS release, same app build.

    On Jun 21, 2012, at 2:13 PM, Chad Hulbert wrote:

    > Sharing preferences between applications is not something you can rely on in
    > a sandboxed environment.

    --
    Scott Ribe
    <scott_ribe...>
    http://www.elevated-dev.com/
    (303) 722-0567 voice
  • On Thu, Jun 21, 2012 at 10:27 PM, Scott Ribe
    <scott_ribe...> wrote:
    > I'm not sandboxed, and the preferences I'm sharing are between my own apps. Also it variously works then doesn't work for a while on the same machine, same OS release, same app build.

    Can you post a small sample code showing how you save and read your preferences?

    Are you calling CFPreferencesSetAppValue, CFPreferencesSetMultiple or
    CFPreferencesSetValue? Are you calling CFPreferencesAppSynchronize?
  • Because of the annoyance of sandboxing on iOS, I've been thinking how to write simple prefs outside the app so that I know the pref is written when I write it (no, iCloud is not a suitable solution).

    Currently, I'm thinking of these options:

    Declare an address, a music file or a picture as a database.

    Write to it.

    In a PNG image, we have 8 bits of R, G, B and A (at least) so we can get 4 ascii chars per image using each value as an ASCII character.

    Considering that there are a boatload of ascii chars that we never use, this could be extended rather easily if needed. (We really only need chars 32 to 126 for basic English (94 chars) so without much effort, it's easy to squeeze two ASCII chars into one 8 bit group by using the value of first four bits as one char and the second four bits as the second char.

    This means that one 8 bit RGBA PNG pixel can be treated as a block of 8 ASCII characters.

    TL;DR: 1 pixel = 8 chars.

    It's seriously shameful that we have to resort to this level of BS thanks to Apple's sandboxing policies, to simply store a damn preference to the device.

    The amount of time we have to waste to simply find out a method to write to our device is sad.  Thanks Apple.

    On Jun 21, 2012, at 2:17 PM, Michael Domino wrote:

    > Hi all,
    >
    > My preferences code strictly uses the CFPreferences api and has worked reliably since Tiger. On Mountain Lion Preview 4 (with the recent update), though, preferences writing has been erratic, sometimes my preferences are updated correctly, sometimes not. Are there any known issues with CFPreferences on Mountain Lion?
    >
    > I found this similar problem another developer is having:
    >
    > https://groups.google.com/forum/?fromgroups#!topic/munki-dev/fzp3SubBTJ0
    >
    > There is a statement there, "In 10.8 preferences are all cached by a preference daemon, and the point at which it reads from/writes to disk is not reliable..." Is that true? Is so, how can one be sure that preferences are updated at all? Is there any doc on the behavior of cfprefsd? The man page says basically nothing.
    >
    > Thanks,
    > Michael Domino
previous month june 2012 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  
Go to today