"Prevent App Nap" check box not available for Cocoa builds

  1. 3 years ago

    Roger M

    2 Mar 2016 Southern California, USA

    What could cause the "Prevent app nap" check box on the "Get info" page of a Cocoa build of a Xojo to not be available? I noticed that none of my Cocoa builds have that check box available.

  2. Christian S

    2 Mar 2016 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    If Xojo links with latest SDK the option is not available.
    Please use process activity functions.

  3. Christian S

    2 Mar 2016 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    With MBS plugin see here
    http://www.monkeybreadsoftware.net/process-nsprocessinfombs-method.shtml#3

  4. Roger M

    2 Mar 2016 Southern California, USA

    @ChristianSchmitz If Xojo links with latest SDK the option is not available.

    Uhm, on the chance of sounding dumb, what does this mean exactly?

  5. Kimball L

    2 Mar 2016 Pre-Release Testers, Xojo Pro Meridian, ID, USA

    In a nutshell: Apple changed the libraries that the latest apps can use, and AppNap is not there the way it used to be. You can still get your app to enter AppNap by using declares or by using Christian's plugin he mentions above.

  6. Roger M

    2 Mar 2016 Southern California, USA

    I see, thanks. I actually want to prevent my from entering AppNap. Wasn't there a plist entry that would also prevent AppNap? Does that still work?

  7. Christian S

    2 Mar 2016 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    you can try.

    The checkbox is for old apps.
    Modern apps should declare activity, so the system can decide more clever.

  8. Marco H

    3 Mar 2016 Pre-Release Testers Cali, Colombia

    If you happen to use NSUserDefaults to save your preferences, try to add Boolean NSAppSleepDisabled = False.
    Not sure if that's the official way but it works for me.

  9. scott b

    3 Mar 2016 Pre-Release Testers, Xojo Pro local coffee shop

    @Roger M on the chance of sounding dumb

    asking questions here doesnt make you sound dumb. especially like what you have done, you have tried to figure it out on your own already.

  10. Kimball L

    3 Mar 2016 Pre-Release Testers, Xojo Pro Meridian, ID, USA

    And if you are interested in seeing how to do it using the MBS plugins:

    To prevent AppNap, create an NSProcessInfoActivityMBS object, and then call beginActivity with it:

    dim SleepDisableHandle as NSProcessInfoActivityMBS
    SleepDisableHandle = NSProcessInfoMBS.processInfo.beginActivity(NSProcessInfoMBS.NSActivityBackground, "Sync running")

    To allow AppNap again, just call endActivity with the same NSProcessInfoActivityMBS object:

    NSProcessInfoMBS.processInfo.endActivity(SleepDisableHandle)
  11. Sam R

    3 Mar 2016 Pre-Release Testers, Xojo Pro Hengchun, Pingtung, Taiwan

    @Roger M I see, thanks. I actually want to prevent my from entering AppNap. Wasn't there a plist entry that would also prevent AppNap? Does that still work?

    The plist entry is for background apps, which do not enter App Nap automatically?????

    For the declare junkies, here's NSProcessInfo I made earlier with a washing up liquid bottle, some sticky backed plastic and a bazooka!
    http://www.ohanaware.com/xojo/NSProcessInfo.zip

    There is a bug in my demo application, the key should be NSProcessInfo.NSActivityUserInitiatedAllowingIdleSystemSleep, otherwise the system never sleeps...

  12. Christian S

    3 Mar 2016 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    when NSProcessInfoActivityMBS object goes out of scope,it will automatically do the endActivity call for you.

  13. Christoph D

    4 Mar 2016 Pre-Release Testers, Xojo Pro

    Is it good/correct practise to make this a preference in your app so the user can enable/disable this himself?

  14. Ulrich B

    4 Mar 2016 Pre-Release Testers, Xojo Pro Europe (Germany, Berlin) · xo...

    @Christoph Dnbsp;Vocht Is it good/correct practise to make this a preference in your app so the user can enable/disable this himself?

    Usually the user shouldn’t need to care. It should be the programmer who decides if his app needs to be running all the time or only when it’s the foreground app.

  15. Sam R

    4 Mar 2016 Pre-Release Testers, Xojo Pro Hengchun, Pingtung, Taiwan

    It depends on what you want.

    For instance Backup To Go, sits there napping until it's time, at which point it throttles up to copy files as fast as it can. Then goes back to sleep.

  16. 10 months ago

    Christoph D

    12 Jul 2018 Pre-Release Testers, Xojo Pro
    Edited 10 months ago

    One of my customers says my app is crashing every time when he opens his MBP after many hours of inactivity. I have a hunch it has something to do with Appnap.

    I use the below code in the App open event to disable Appnap.

    dim SleepDisableHandle as NSProcessInfoActivityMBS
    SleepDisableHandle = NSProcessInfoMBS.processInfo.beginActivity(NSProcessInfoMBS.NSActivityBackground, "Sync running")

    Maybe an app that has Appnap disabled, triggers the App.open event after the system gets back from inactivity? Is this possible?

    Also, is there a way to force the system to enter Appnap?

  17. Christian S

    13 Jul 2018 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    Crash log?

  18. Christoph D

    14 Jul 2018 Pre-Release Testers, Xojo Pro

    Here is a crash report:
    Seems there are too many wake ups ?

    Date/Time: 2018-07-02 16:19:18.344060 +1000
    OS Version: Mac OS X 10.13.5 (Build 17F77)
    Architecture: x86_64
    Report Version: 19

    Command: XDevices
    Path: /Applications/01Apps/XDevices.app/Contents/MacOS/XDevices
    Version: 1.1.1 (1.1.1)
    Parent: launchd [1]
    PID: 42602

    Event: wakeups
    Action taken: none
    Wakeups: 45001 wakeups over the last 211 seconds (213 wakeups per second average), exceeding limit of 150 wakeups per second over 300 seconds
    Wakeups limit: 45000
    Limit duration: 300s
    Wakeups caused: 45001
    Duration: 210.80s
    Steps: 23

    Hardware model: iMac15,1
    Active cpus: 8

    Fan speed: 1196 rpm

    Powerstats for: ff·Works [42602]
    UUID: A5F92A22-D802-3796-83E2-F467693DBC79
    Start time: 2018-07-02 16:19:19 +1000
    End time: 2018-07-02 16:22:48 +1000
    Parent: launchd
    Microstackshots: 23 samples (100%)
    Primary state: 11 samples Frontmost App, User mode, Effective Thread QoS User Interactive, Requested Thread QoS User Interactive, Override Thread QoS Unspecified
    User Activity: 0 samples Idle, 23 samples Active
    Power Source: 0 samples on Battery, 23 samples on AC
    20 start + 1 (libdyld.dylib) [0x7fff6aac7015]
    20 main + 19 (ff·Works) [0x1044db7f3]
    20 _Main + 478 (ff·Works) [0x1044dd90e]
    20 REALbasic._RuntimeRun + 19 (ff·Works) [0x102b45b23]
    20 RuntimeRun + 40 (XojoFramework) [0x104fbf17f]
    20 -[NSApplication run] + 764 (AppKit) [0x7fff40246885]
    20 ??? (XojoFramework + 865878) [0x104e40656]
    20 CallFunctionWithExceptionHandling(void (*)()) + 262 (XojoFramework) [0x104fc0e53]
    20 Application._CallFunctionWithExceptionHandling%%o<Application>p + 181 (ff·Works) [0x102a96045]
    20 ??? (XojoFramework + 866029) [0x104e406ed]
    20 ??? (XojoFramework + 865961) [0x104e406a9]
    20 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3044 (AppKit) [0x7fff409e7e34]
    19 _DPSNextEvent + 2085 (AppKit) [0x7fff40251a73]
    19 _BlockUntilNextEventMatchingListInModeWithFilter + 64 (HIToolbox) [0x7fff41f9f884]
    18 ReceiveNextEventCommon + 613 (HIToolbox) [0x7fff41f9fb06]
    18 RunCurrentEventLoopInMode + 286 (HIToolbox) [0x7fff41f9fd96]
    18 CFRunLoopRunSpecific + 483 (CoreFoundation) [0x7fff42cb91a3]
    13 __CFRunLoopRun + 2427 (CoreFoundation) [0x7fff42cb9dab]
    11 __CFRunLoopDoTimers + 346 (CoreFoundation) [0x7fff42cc27da]
    7 __CFRunLoopDoTimer + 1095 (CoreFoundation) [0x7fff42cc2cd7]
    7 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20 (CoreFoundation) [0x7fff42cc3064]
    4 ??? (XojoFramework + 2474041) [0x104fc9039]
    2 MainWindow.MainWindow.E7_Action%%o<MainWindow.MainWindow>o<Timer> + 506 (ff·Works) [0x103063f9a]
    2 SecStaticCodeCheckValidityWithErrors + 163 (Security) [0x7fff4ebc5b42]
    2 Security::CodeSigning::SecStaticCode::staticValidate(unsigned int, Security::CodeSigning::SecRequirement const*) + 71 (Security) [0x7fff4ebcd33d]
    2 Security::CodeSigning::SecStaticCode::staticValidateCore(unsigned int, Security::CodeSigning::SecRequirement const*) + 47 (Security) [0x7fff4ebcf4a1]
    2 Security::CodeSigning::SecStaticCode::validateExecutable() + 584 (Security) [0x7fff4ebc9e9c]
    2 Security::CodeSigning::CodeDirectory::multipleHashFileData(Security::UnixPlusPlus::FileDesc, unsigned long, std::__1::set<unsigned int, std::__1::less<unsigned int>, std::__1::allocator<unsigned int> >, void (unsigned int, Security::DynamicHash*) block_pointer) + 416 (Security) [0x7fff4ebd7cec]
    2 Security::makeCFMutableDictionary() + 27 (Security) [0x7fff4ece0c2c]
    2 CFDictionaryCreateMutable + 207 (CoreFoundation) [0x7fff42c3ea3f]
    2 CFBasicHashCreate + 827 (CoreFoundation) [0x7fff42c3711b]
    2 CFBasicHashGetPtrIndex + 77 (CoreFoundation) [0x7fff42c375bd]
    1 MainWindow.MainWindow.E9_Action%%o<MainWindow.MainWindow>o<Timer> + 791 (ff·Works) [0x103069d67]
    1 SecStaticCodeCheckValidityWithErrors + 163 (Security) [0x7fff4ebc5b42]
    1 Security::CodeSigning::SecStaticCode::staticValidate(unsigned int, Security::CodeSigning::SecRequirement const*) + 71 (Security) [0x7fff4ebcd33d]
    1 Security::CodeSigning::SecStaticCode::staticValidateCore(unsigned int, Security::CodeSigning::SecRequirement const*) + 47 (Security) [0x7fff4ebcf4a1]
    1 Security::CodeSigning::SecStaticCode::validateExecutable() + 584 (Security) [0x7fff4ebc9e9c]
    1 Security::CodeSigning::CodeDirectory::multipleHashFileData(Security::UnixPlusPlus::FileDesc, unsigned long, std::__1::set<unsigned int, std::__1::less<unsigned int>, std::__1::allocator<unsigned int> >, void (unsigned int, Security::DynamicHash*) block_pointer) + 411 (Security) [0x7fff4ebd7ce7]
    1 Security::CodeSigning::scanFileData(Security::UnixPlusPlus::FileDesc, unsigned long, void (void const*, unsigned long) block_pointer) + 145 (Security) [0x7fff4ebf3cb1]
    1 invocation function for block in Security::CodeSigning::CodeDirectory::multipleHashFileData(Security::UnixPlusPlus::FileDesc, unsigned long, std::__1::set<unsigned int, std::__1::less<unsigned int>, std::__1::allocator<unsigned int> >, void (unsigned int, Security::DynamicHash*) block_pointer) + 50 (Security) [0x7fff4ebd7deb]

  19. Beatrix W

    14 Jul 2018 Pre-Release Testers Europe (Germany)

    That's not a crashlog. Whatever is happing here is to do with your code signing and what you do to check the code signing.

  20. Newer ›

or Sign Up to reply!