Handbrake, OS X 10.8 Mountain Lion, and system sleep

HandBrake for Mac support
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
baggss
Moderator
Posts: 886
Joined: Tue Jan 02, 2007 8:21 am

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by baggss »

Maybe I'm missing something but I've been running HB for more or less 3 days strait now with no crashed to either HB or the OS. I have my 27 inch iMac set to Never sleep and to never sleep the HDDs and all seems to be working properly. I'm running the stock 0.9.8 HB off the web site and 10.8.2 with all the latest updates and it works fine. Never had an issue with my previous 21 inch iMac that I just switched from either (same OS).
jlacube
Posts: 13
Joined: Thu Sep 06, 2012 7:50 am

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by jlacube »

baggss wrote:Maybe I'm missing something but I've been running HB for more or less 3 days strait now with no crashed to either HB or the OS. I have my 27 inch iMac set to Never sleep and to never sleep the HDDs and all seems to be working properly. I'm running the stock 0.9.8 HB off the web site and 10.8.2 with all the latest updates and it works fine. Never had an issue with my previous 21 inch iMac that I just switched from either (same OS).
There were quite different subjects in this topic, however the patch I'm working on is only addressing one thing,the power assertions in osx. Basically it will subscribe a "prevent" power assertion if HB is scanning and/or encoding. The assertions will be released when the jobs are done. It also handles Pause/Resume cases.

All other matters (namely crashed, reboot, etc) were never confirmed afterwards (especially not linked to OSX power assertions)
voip-ninja
Posts: 18
Joined: Tue Jan 29, 2013 5:54 pm

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by voip-ninja »

baggss wrote:Maybe I'm missing something but I've been running HB for more or less 3 days strait now with no crashed to either HB or the OS. I have my 27 inch iMac set to Never sleep and to never sleep the HDDs and all seems to be working properly. I'm running the stock 0.9.8 HB off the web site and 10.8.2 with all the latest updates and it works fine. Never had an issue with my previous 21 inch iMac that I just switched from either (same OS).
The idea is that Handbrake would use the new OS X sleep assertions, in which an app, when doing work, can ask OS X not to go to sleep. For example, if I'm ripping something with MakeMKV, my mac won't sleep because MakeMKV has added these insertions.

I'm hoping we will see this baked into a nightly build soon, as needing to run caffeinate is kind of a PITA and is needed when using Handbrake (vs disabling sleep on my Mac which I don't want to add).
jlacube
Posts: 13
Joined: Thu Sep 06, 2012 7:50 am

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by jlacube »

voip-ninja wrote:
baggss wrote:Maybe I'm missing something but I've been running HB for more or less 3 days strait now with no crashed to either HB or the OS. I have my 27 inch iMac set to Never sleep and to never sleep the HDDs and all seems to be working properly. I'm running the stock 0.9.8 HB off the web site and 10.8.2 with all the latest updates and it works fine. Never had an issue with my previous 21 inch iMac that I just switched from either (same OS).
The idea is that Handbrake would use the new OS X sleep assertions, in which an app, when doing work, can ask OS X not to go to sleep. For example, if I'm ripping something with MakeMKV, my mac won't sleep because MakeMKV has added these insertions.

I'm hoping we will see this baked into a nightly build soon, as needing to run caffeinate is kind of a PITA and is needed when using Handbrake (vs disabling sleep on my Mac which I don't want to add).
The patch is in review here : https://reviews.handbrake.fr/r/348/
For now most of the reviewers validated it, probably going to integrated soon if everyone agree on the design.
baggss
Moderator
Posts: 886
Joined: Tue Jan 02, 2007 8:21 am

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by baggss »

voip-ninja wrote:
baggss wrote:Maybe I'm missing something but I've been running HB for more or less 3 days strait now with no crashed to either HB or the OS. I have my 27 inch iMac set to Never sleep and to never sleep the HDDs and all seems to be working properly. I'm running the stock 0.9.8 HB off the web site and 10.8.2 with all the latest updates and it works fine. Never had an issue with my previous 21 inch iMac that I just switched from either (same OS).
The idea is that Handbrake would use the new OS X sleep assertions, in which an app, when doing work, can ask OS X not to go to sleep. For example, if I'm ripping something with MakeMKV, my mac won't sleep because MakeMKV has added these insertions.

I'm hoping we will see this baked into a nightly build soon, as needing to run caffeinate is kind of a PITA and is needed when using Handbrake (vs disabling sleep on my Mac which I don't want to add).
My point was that there were claims that this occurred even when the Mac was set to not go asleep, which I find odd. I'm going to assume I've never seen any issues because my iMac is set to never go to sleep. I ended up ripping for a bit over 4 days strait before I had to stop, and then only because I wasn't going to be home to feed more discs into the beast.
jlacube
Posts: 13
Joined: Thu Sep 06, 2012 7:50 am

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by jlacube »

ok got you. Macs going to sleep even when set the "Never sleep" was a rare symptom only appearing on early version of ML IIRC...
At least since 10.8.1, this problem, as you said, only concerns people having the sleep function enabled (to any value).
voip-ninja
Posts: 18
Joined: Tue Jan 29, 2013 5:54 pm

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by voip-ninja »

I see that it's made it into the last couple of nightlies, will be testing it out shortly! :)

Thanks again for patching it.
voip-ninja
Posts: 18
Joined: Tue Jan 29, 2013 5:54 pm

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by voip-ninja »

Doesn't seem to be quite working. The first time I used it, it seemed to keep my Mac awake and let my encode run (when I woke the Mac up the handbrake encode had completed). However, last night I queued up several titles and left the Mac running. This morning when Handbrake woke up, only the first title had completed, the other items in the queue did not run. Perhaps it is not preventing the Mac from sleeping between the time that one encode completes and the next one is kicked off.
Deleted User 11865

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by Deleted User 11865 »

That should only last a couple seconds - I guess Mac OS X is really checking very often for that kind of thing.
voip-ninja
Posts: 18
Joined: Tue Jan 29, 2013 5:54 pm

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by voip-ninja »

Yeah, looking at the logs it's not clear to me what borked it up. I will queue some more stuff up tonight and try again. Is there any debugging options that would show me what Handbrake is doing with the sleep stuff?
voip-ninja
Posts: 18
Joined: Tue Jan 29, 2013 5:54 pm

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by voip-ninja »

Same thing happened last night. Looks like out of a queue of four titles, titles 1-2 ran and then the Mac went to sleep. There could be a problem with how the assertion is being done, maybe it needs to be re-asserted each time or perhaps it is being de-asserted after each encode and OS X thinks it's time to go nighty night.
Deleted User 11865

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by Deleted User 11865 »

voip-ninja wrote:perhaps it is being de-asserted after each encode
That is correct. I guess we need to be more aggressive about this.
voip-ninja
Posts: 18
Joined: Tue Jan 29, 2013 5:54 pm

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by voip-ninja »

How difficult would it be for Handbrake to look at all of the titles that are queued and not issue the de-assertion until the queue is completed or the user interrupts it?
voip-ninja
Posts: 18
Joined: Tue Jan 29, 2013 5:54 pm

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by voip-ninja »

I am always doing batches of encodes so if there are logs that would be helpful let me know and I'll provide them.
jlacube
Posts: 13
Joined: Thu Sep 06, 2012 7:50 am

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by jlacube »

We're already doing the assertion outside the loop in the working thread, so the assertion should be still valid.
I'll do some tests this weekend but probably, we will need to get back to a higher level functions than the working thread...

If I find an easy (and efficient) fix, I'll reopen the review and submit it during the weekend
Deleted User 11865

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by Deleted User 11865 »

jlacube wrote:We're already doing the assertion outside the loop in the working thread, so the assertion should be still valid.
Yeah but the loop is old… it doesn't handle the queue anymore. The queue is now handled by the UIs.
jlacube
Posts: 13
Joined: Thu Sep 06, 2012 7:50 am

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by jlacube »

yep, that's what I just found out this evening :-)

I tested the fix and now we have the correct behaviour for queued encoding.
So the changes are very limited, but still I'm not very happy with the new design...
I moved hb_prevent_sleep & hb_allow_sleep from internal.h to common.h, and I moved the assertions subscription from work.c to Controller.m
Basically it's working well now, but the goal of having the code in libhb was to be generic, so calling it from OSX UI code makes it quite not necessary in the sense that we can probably have everything back into OSX UI code then...

Another way would be to add a new function callable from UI to specify that we are doing batch encoding and so sleep/prevent functions should be called until later, but then we will have a problem for release process...

I reopened/updated the review if you want to have a look at my current solution
voip-ninja
Posts: 18
Joined: Tue Jan 29, 2013 5:54 pm

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by voip-ninja »

Thanks fellas for continuing to plink away at this.
voip-ninja
Posts: 18
Joined: Tue Jan 29, 2013 5:54 pm

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by voip-ninja »

Were the queuing issues patched in 5252?
voip-ninja
Posts: 18
Joined: Tue Jan 29, 2013 5:54 pm

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by voip-ninja »

Running 5262 it is still not staying awake between queue items and interestingly, now, the Mac is locking up when it's going to sleep with HandBrake doing a batch encode job. It was not doing this with the previous load I was running, 5242.
Deleted User 11865

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by Deleted User 11865 »

No changes related to system sleep since we committed Jérôme's first patch. Someone will post here if/when something new is committed.
voip-ninja
Posts: 18
Joined: Tue Jan 29, 2013 5:54 pm

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by voip-ninja »

Rodeo wrote:No changes related to system sleep since we committed Jérôme's first patch. Someone will post here if/when something new is committed.
Thanks.
jlacube
Posts: 13
Joined: Thu Sep 06, 2012 7:50 am

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by jlacube »

voip-ninja wrote:
Rodeo wrote:No changes related to system sleep since we committed Jérôme's first patch. Someone will post here if/when something new is committed.
Thanks.
Hi voip-ninja,

I would like to check some info with you regarding this feature.

Can you please tell me:
- The size/type of files you're encoding in batches
- A very rough estimation of the scanning time of each title you're encoding (I'm looking for something like a few seconds, ten seconds, thirty seconds, a minute, etc.
- Your OSX version
- Your current power savings settings
- Your mac's type (just laptop, mac mini or mac pro will be enough)

If you want you can send me these by PM, that's fine.

I'm still digging on this (and hopefully I will find the bottom soon :-) )
It ***seems*** that activating the power assertions/de-assertions during scan "fix" the pbm.
However I want to check if it's really a fix a just the fact that my video samples are simple and short enough to mask the problem.
If this is true it would mean that OSX is actually incrementing a counter of seconds of inactivity which is not reinitialize after reassertions from the program (and with the same ID) but we're not there yet, I hope this time it's really a fix.
voip-ninja
Posts: 18
Joined: Tue Jan 29, 2013 5:54 pm

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by voip-ninja »

I don't mind posting the data here;

Most of my file sizes are blu-ray source MKVs (individual episodes of a TV season for example). So I would say that usually my source files are each about 3-10 GB and scan in < 5-10 seconds.

I am on OSX 10.8.2

I have an i7 based iMac. An item of note is that it is Fusion drive which I think changes the sleep behavior slightly (it uses a laptop style sleep image if I remember correctly).

System sleep in 12 minutes - Display sleep in 12 minutes. Put hard disks to sleep when possible is checked and allow power button to put computer to sleep is also checked. I am not using a sleep schedule, only the sleep controls just described.
Deleted User 11865

Re: Handbrake, OS X 10.8 Mountain Lion, and system sleep

Post by Deleted User 11865 »

I just pushed a number of commits related to system sleep:

https://trac.handbrake.fr/changeset/5336
https://trac.handbrake.fr/changeset/5337
https://trac.handbrake.fr/changeset/5338
https://trac.handbrake.fr/changeset/5339
https://trac.handbrake.fr/changeset/5340

…they'll be in tomorrow's nightly. Hopefully we're all set for the next release.

Please report any relevant issues here.
Post Reply