Hi,
I've been using
IOReturn success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reasonForActivity, &assertionID);
as detailed in this Tech Q & A to prevent the screen saver from activating in certain phases of my app. Unfortunately, since 10.11 this seems to have stopped working. There are no errors, no extra log lines generated, the app works absolutely fine and the only difference in it's operation - in El Capitan - is that the screen saver continues to show after the prerequisite amount of time.
Does anyone know if there's been a change to the process of preventing this? I can't seem to find anything in docs...
Todd.
Interesting. I can still get power assertions to work on El Capitan, using this code:
IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn,(CFStringRef)@"Preventing Sleep", &_assertionID1)
I don't know why your code seems to have stopped working. Have you verified that the code works under Yosemite? Make sure you use an identical build of the app, then test on both platforms. It seems likely to me that something you did is keeping it from working. It could be an unintentional side effect that happens only on El Capitan, but I still think it might have something to do with your code.
You might also want to try using the new power assertion API introduced back in OS X Mavericks (10.9, released in 2013), which looks like this:
id token = [NSProcessInfo.processInfo beginActivityWithOptions:NSActivityIdleDisplaySleepDisabled reason:@"Preventing Sleep"];
...
[NSProcessInfo.processInfo endActivity:token];
This newer API might not have the same side effects—it's worth a try.