Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Hotkey to pause/stop video #1156

Open
klamike opened this issue Feb 21, 2021 · 12 comments
Open

Feature Request: Hotkey to pause/stop video #1156

klamike opened this issue Feb 21, 2021 · 12 comments

Comments

@klamike
Copy link

klamike commented Feb 21, 2021

Description of issue / Feature request

I'm really enjoying Aerial so far - I have it set up on my Late 2013 MBPr hooked up to an external 4k monitor in clamshell mode. Unfortunately, any time Aerial is running, GPU usage goes up and so the fans spin up. As soon as I log in and start just using a browser/regular apps, the fans turn off.

The feature I'd like to request is a hotkey toggle that pauses the video on the screensaver to stop using the GPU. Or, if there is a way to detect if the monitor is off via DDC/CI (ddcctl) that would be cool to integrate too!

@glouel
Copy link
Collaborator

glouel commented Feb 21, 2021

Hey @klamike

A few things :

  • So regarding hotkey, sadly that's not possible, screensavers are no longer allowed (post Catalina) to intercept key presses. That may come back some day, hopefully

  • Regarding monitor off, are you saying you are manually turning it off, and Aerial keeps running ? In general I would suggest you use the power saving preferences where you can set for how long your screensaver should run. This way you can at least limit it a bit (that slider) :

Capture d’écran 2021-02-21 à 17 56 12

I do believe that Aerial gets notified if a screen gets connected/disconnected, though I haven't played much with that, there may be something I can do around that, I'll make a note to investigate.

  • Regarding CPU/GPU usage, on a 2013 MBP, off the top of my head, you don't have hardware decoding on the Intel IGP for HEVC decoding, so 4K HEVC (and even 1080p HEVC) will be a bit taxing on your CPU, more than the GPU. If you use 4K HDR however, you're adding some GPU load because of the Dolby Vision color processing. 1080p H.264will not spin your fan but that's not really a satisfactory solution, that's just a limitation of those Mac generations.

Let me know if that clears things up.

@klamike
Copy link
Author

klamike commented Feb 21, 2021

Thanks for the quick reply! I have it set to 4K HEVC and this is what the usage graphs look like through Activity Monitor:

Screen Shot 2021-02-21 at 12 13 36 PM

You can clearly see when the screensaver is on/off from the GPU graph. Looks like the CPU usage also goes up above background levels (a few apps open, not streaming any video) when Aerial is on.

Unfortunate that screensavers can't intercept key presses. Maybe a triple mouse click or something can work?

@glouel
Copy link
Collaborator

glouel commented Feb 21, 2021

As far as I know the decoding is always done on the CPU, so that's probably what you are hearing, the GPU usage in activity monitor is not always representative of a "tough" load (it's not doing 3D rendering). What it does here is just rendering the video (with some 10 bit processing but not very hard).

You can double check for yourself playing one of the videos from the cache, directly in Quicktime. Aerial uses macOS's system decoding APIs so what you get in Aerial and Quicktime should be 100% similar. I would guess CPU temperature is what makes the fan kicks in but I can be wrong.

Mouse is clamped down as much as keyboard, there's really no way to interact with a running screensaver nowadays.

You didn't answer my question regarding the monitor thing btw.

@klamike
Copy link
Author

klamike commented Feb 21, 2021

Oh sorry about that - Yes it does appear that Aerial is still running since the fans don't turn down when the monitor is off.

I just verified by looking at the usage graphs as well which tell the same story - turning off monitor has no affect on GPU or CPU load.

Also, verified that the loads are the same between screensaver and Quicktime from cache.

@glouel
Copy link
Collaborator

glouel commented Feb 21, 2021

Ok then.

I'll keep this open and try to have a look if I can detect a monitor off event and do something about it. In the meantime I suggest you clamp down the running time with the setting above.

I'll try to have a look this week but no promise :)

@klamike
Copy link
Author

klamike commented Feb 21, 2021

Awesome, thanks again for the help and quick response!

@glouel
Copy link
Collaborator

glouel commented Feb 22, 2021

@klamike

Ok so, had some time this morning to look at this, and unfortunately it's not really great news :

  • First, I did a quick check and here at least, I don't get any event from macOS's display APIs when I power off/standby my external monitor. What I get is events for plugged/unplugged monitor. A standbyed monitor is still seen as connected by macOS, and thus it doesn't stop rendering stuff there. So, no easy fix this way
  • I did look at ddcctl, and it flat out doesn't work with my external monitor on my old Intel iMac :
$ ./ddcctl -d 1 -p ?
D: CGDisplay CD30F1A3-6617-FB04-0D8C-5C0EA5A6B477 dispID(#441231492) (3008x1692 0°) HiDPI
I: found 1 external display
I: polling EDID for #1 (ID 441231492 => IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/PEG0@1/IOPP/GFX0@0/ATY,Labrador@4/AMDFramebufferVI)
E: Failed to poll display!

Now I can't totally blame the project, this is a weird screen I'm using (an Asus PQ321, one of the first 4K DP display that only used one cable, doing MST). It's very likely that the firmware on this thing is borked. While it's connected straight with a mini DP to DP cable (no dongle which is the issue most of the time for that error), it still errors on me which makes it hard to even implement something like this.

  • I also did try many ioreg commands and I don't get anything meaningful regarding power states. Maybe I'm looking at the wrong one but running :

ioreg -c IODisplayConnect -b -f -r -l -i -d 2

I always get state 3, whether it's on or off :

"IOPowerManagement" = {"DevicePowerState"=3,"CurrentPowerState"=3,"CapabilityFlags"=49152,"MaxPowerState"=3}

Could you try the commands above (ioreg and ddcctl), with your screen on and off, and see if it reads the power state ?

So I'm very reluctant to work on something that will only work for some, and won't work going forward unless Apple reverts their decision on not implementing I2C on arm. This is not really satisfying, I would have loved to also use this to control brightness on external displays but if it doesn't work on arm, there's little point wasting efforts on it.

@klamike
Copy link
Author

klamike commented Feb 22, 2021

Totally understand that it's not worth the time if Apple is going to make it obsolete soon anyway, especially since this is a pretty niche feature too.

I tried the commands and it looks like ddcctl does recognize the power state (or at least some differences) for my monitor:

Power on:

$ ddcctl -d 1 -p ?
D: NSScreen #1007443977 (1920x1080 0°) HiDPI
I: found 1 external display
I: polling display 1's EDID
I: got edid.name: HP Z27s
I: got edid.serial: redacted
D: action: p: ?
D: querying VCP control: #214 =?
I: VCP control #214 (0xd6) = current: 5, max: 4

Power off:

$ ddcctl -d 1 -p ?
D: NSScreen #1007443977 (1920x1080 0°) HiDPI
I: found 1 external display
I: polling display 1's EDID
I: got edid.name: HP Z27s
I: got edid.serial: redacted
I: got edid.name: 
I: got edid.serial: äþ
D: action: p: ?
D: querying VCP control: #214 =?
E: No data after 10 tries! 
E: DDC send command failed!
E: VCP control #214 (0xd6) = current: 0, max: 0

My output for ioreg is the same as yours - the power state is 3 regardless.

Do you have a link for me to buy you coffee? Really appreciate the time you've been putting in on this issue and I'm loving Aerial in general.

@glouel
Copy link
Collaborator

glouel commented Feb 22, 2021

Ha interesting, so ioreg wasn't what I was looking for.

The way ddcctl works is a bit weird here though, basically the command fails when you power off, you don't get a real reply (that may happen in other situations too, so maybe not the best thing to poll regularly...). The return code for off should be 2 or 1 apparently (depending on what they call standby and poweroff)

I'm wondering though if all monitors work the same way here, of if this depends on the type of power off. It's not fully off since apparently it replies to the EDID polling, but not the DCC commands. Do you happen to have two power off buttons (like a "soft" power off that puts it on standby, and maybe another one at the back or something ? Just curious on how this is supposed to work.

If you feel adventurous, maybe try powering it off with :

$ ddcctl -d 1 -p 2

or maybe

$ ddcctl -d 1 -p 1

Does it look "off" the same way that it does when you do it by pressing whatever button ?

Still if there's a reliable way to do this in the future (and also control brightness for external monitors) I'd love to add it, as niche as it is. Aerial is already full of niche stuff ;)

Regarding coffee, no need but if you really want to, there's a link in the about box of Aerial, it goes here : https://ko-fi.com/glouel

@klamike
Copy link
Author

klamike commented Feb 22, 2021

There are two buttons - one on the back to cut power and one on the front to standby.

$ ddcctl -d 1 -p 1 makes it blink off then back on. Running this after setting state 2, 3, 4 turns the monitor back on
$ ddcctl -d 1 -p 2 makes it go to sleep (standby I guess? front led is goes from white to orange), can't wake with mouse/keyboard input like usual though (need to press the front button twice to turn the monitor off fully then back on again)
$ ddcctl -d 1 -p 3 same as 2 as far as I can tell
$ ddcctl -d 1 -p 4 makes it turn off completely (front led goes off too) but to turn back, I just press the front button once or set state to 1.
$ ddcctl -d 1 -p 5 same as 4 but you can't turn the monitor back on with -p 1 from this state, only the front button works

Over 6 does nothing. Hope this helps, I realize it's super weird behavior...

@glouel
Copy link
Collaborator

glouel commented Feb 22, 2021

Ok great. According to your previous test, 5 should be on, so I guess maybe your monitor doesn't handle that command in a write fashion correctly (it kinda reads in reverse, like 1 is on and it goes "more" off as you go down, but that goes against your previous test.

I did try powering up my PC but there doesn't seem to be an equivalent for windows (there's softMCSS that can read things, but not raw values, and my monitor on that machine is very old and doesn't support writing to that command) and I don't have a linux box with a monitor connected at the moment so I can't double check, I'll see if I can try something else, this is mostly out of curiosity at this point.

But just to confirm, when you powered it off on your test in the previous message, did you press the front button, or the back button ? I would assume that you did front ?

@klamike
Copy link
Author

klamike commented Feb 22, 2021

Yep just the front. The back button is for the power supply, the monitor isn't seen at all when it's off via the back button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants