obsproject / obs-studio

OBS Studio - Free and open source software for live streaming and screen recording
https://obsproject.com
GNU General Public License v2.0
60.08k stars 7.95k forks source link

MacBook M1 hotkey issues - not working when not in focus and erratically when in focus. #4126

Closed verstaerker-583 closed 2 months ago

verstaerker-583 commented 3 years ago

Platform

Operating system and version: macOS Big Sur 11 - MacBook Pro (13", M1, 2020) OBS Studio version: 26.1.2

Expected Behavior

Hotkeys should work as expected/ defined, both with OBS in and out focus.

Current Behavior

Hotkeys do not work when OBS is not in focus. And when in focus, after about 5-10 keypresses, my scene collection reacts as OBS would receive multiple additional keypresses - Resetting security & privacy settings and also adding OBS manually did not help.

Restarting OBS "fixes" the erratic behavior for about 5-10 keypresses, it does not help with keypresses while OBS in not in focus.

I am not using modifier keys in my configurations.

Hammerspoon running in parallel is reacting to hotkeys as expected.

Exactly the same configuration (scene collection, profile, global.ini and Hammerspoon running in parallel) ist just working fine on Intel Macs I have access to: MacBook Air (2017), MacBook Pro (2019) and MacPro (2019).

On the same M1 MacBook hotkeys still worked as expected with OBS Studio 26.0.2 moved to it from an Intel MacBook by the Apple Migration Assistant - even without touching security & privacy settings. For Hammerspoon to work on the new MacBook, it was necessary to remove its keyboard access from the security & privacy settings first.

Please find the scene collection here: https://github.com/verstaerker-583/obs/blob/master/var/ss.json

Deleting TCC databases did not help: rm "~/Library/Application Support/com.apple.TCC/TCC.db"; sudo rm "/Library/Application Support/com.apple.TCC/TCC.db"

This did not help either: HotkeyFocusType=DisableHotkeysOutOfFocus

Steps to Reproduce

Start OBS, check hotkeys with obs in and out focus.

Additional information

hotkeys not working when not in focus on M1 macs seems to be reported often, additional erratic function is seen less often https://obsproject.com/forum/threads/big-sur-hotkey-issues.136859 https://obsproject.com/forum/threads/hot-key-issues.134837 https://obsproject.com/forum/threads/hotkeys-not-working-big-sur-m1-mini.135118 https://obsproject.com/forum/threads/hotkeys-only-work-if-obs-is-the-focused-app.134913 https://obsproject.com/forum/threads/hotkeys-stopped-working-with-an-update-of-obs.115164

FredrikWendt commented 3 years ago

Adding information on modifiers:

None of the F1-F12 keys trigger the Hotkey action (I'm only switching scenes) if there was ANY modifier included in the configuration (Shift, Alt, Command), such as ^F1.

The Control and Shift modifier key seems to be completely ignored. If I configure a hotkey to F1, it triggers regardless if I keep the Control (or Shift, Alt, Command) key pressed or not.

The above behaviour is observed only when OBS application is in focus (tested main window and windowed preview).

I'm using a USB connected Apple keyboard, and I get the same results if I'm using the laptop's keyboard (I've set pressing the F1 button to NOT dim light, but to work as a Fn button).

(I've not observed the erratic behaviour.) OBS 26.1.2 MacBook Air M1, 2020 (16GB RAM) Mac OS Big Sur 11.1

PatTheMav commented 3 years ago

FWIW the entire hotkey implementation in macOS is waiting for a revamp anyway (using OS-based events when not in focus).

meneguzzi commented 3 years ago

So this seems to be a known issue, has anybody figured out a workaround for this problem?

PatTheMav commented 3 years ago

There is no known workaround except the one that Jim already implemented - work on a reimplementation of the hotkey handling was started a few months ago but requires some deeper (read: non-trivial) changes and we didn't have the bandwidth to get back to it yet: https://github.com/obsproject/obs-studio/pull/3914

FredrikWendt commented 3 years ago

@meneguzzi my workaround: kill and restart as quick as you can ... In general, I find that the second launch of OBS in the day, usually doesn't cause any issues - it's just the first launch after the computer's been in hibernation / lid closed over night.

meneguzzi commented 3 years ago

@FredrikWendt I'm afraid that does not work.

peppy commented 3 years ago

Just adding to this as it's a very frustrating issue. I can reproduce breaking behaviour 100% based on the comment at https://obsproject.com/forum/threads/hotkeys-stopped-working-with-an-update-of-obs.115164/page-2#post-504151:

Hotkeys should now be broken until next restart of OBS.

skalero01 commented 3 years ago

have the same issue. Hotkeys works when OBS window is focus. If not it doesn't work on a Mac mini M1

AlexisParra commented 3 years ago

same here on macbook air m1. hotkeys only work when obs is in focus. no combination with alt or cmd is working either, also not when obs is in focus.

abrilevskiy commented 3 years ago

I have also the same issue. Hotkeys works when OBS window is in focus. If not in focus - the hotkeys don't work on a Mac Book Pro macOS Big Sur 11.6. Looks like related to https://github.com/obsproject/obs-studio/pull/3914

samipshah100 commented 2 years ago

I am having the same issues also on macbook air m1 Big Sur.

AlexisParra commented 2 years ago

For some reason it now works for me. No need for OBS to be in focus to use hotkeys. No specific changes made.

samipshah100 commented 2 years ago

Can u use ctrl ans shift keys also for the hotkeys?

Which version of obs?

On Tue, 30 Nov, 2021, 1:36 pm Alexis Pryds Parra, @.***> wrote:

For some reason it now works for me. No need for OBS to be in focus to use hotkeys. No specific changes made.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/obsproject/obs-studio/issues/4126#issuecomment-982379374, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMJ3FQHDYC426YFJR6CQPWDUOSAWRANCNFSM4WQCO7RA .

BeauNouvelle commented 2 years ago

Definitely still an issue. I ended up buying a stream deck to get past this. Hopefully there's an arduino/pico type project out there that can replicate that same functionality on the cheap (and not just pass through keyboard presses).

siddicky commented 2 years ago

Hi, I bought a stream deck and still having the same issue. Also I'm using a MacBook Pro 2019. Hotkeys do not work when out of focus and there is a delay in the scene switcher once the window comes back into fucus.

joshkemp commented 2 years ago

I have tried everything I can think or find online for the past two months to no avail. I've tried multiple wired / wireless keyboards, macro apps, midi apps, Loupedeck, etc with and without modifiers, virtual keyboard apps, standing on my head and spinning in my chair but still cannot get this thing to consistently pickup hotkey presses. It appears to be the exact same issue in both the Rosetta/Intel version as the Mac/M1 version.

leafac commented 2 years ago

I have tried everything I can think or find online for the past two months to no avail. I've tried multiple wired / wireless keyboards, macro apps, midi apps, Loupedeck, etc with and without modifiers, virtual keyboard apps, standing on my head and spinning in my chair but still cannot get this thing to consistently pickup hotkey presses. It appears to be the exact same issue in both the Rosetta/Intel version as the Mac/M1 version.

I found that for the standing-on-the-head-and-spinning-on-the-chair trick to work it’s important that you spin counterclockwise. Perhaps you spun clockwise? 🙃

In all seriousness, though, I’m running OBS on a M1 Mac with Rosetta and global keyboard shortcuts work as they should most of the time. When they don’t, restarting OBS fixes it. My keyboard shortcuts are always control+option+command+KEY. 🤷‍♂️

leafac commented 2 years ago

For what it’s worth:

I updated to OBS 28.0.2 and the issue got worse: Now my favorite kind of keyboard shortcut (control+option+command+KEY) doesn’t work at all 🤷

Other kinds of keyboard shortcut, for example, control+KEY work. I don’t know if they’d stop working after a while…

Note that https://github.com/obsproject/obs-studio/pull/3914 has been merged, so I assume that the reimplementation has happened, right?

RytoEX commented 2 years ago

Multiple hotkey fixes went into OBS Studio 28/28.0.2. For hotkeys to work when OBS is not in-focus, you must enable the Accessibility permission for OBS.

For the described "erratic" nature of hotkeys when OBS is in-focus, please provide one example hotkey combination and specific steps to reproduce that we can test. Please test on OBS Studio 28.0.2 or newer, and preferably on macOS 12 (or latest stable).

siddicky commented 2 years ago

Issue was fixed for me in the latest update (28). Great work team!

leafac commented 2 years ago

@RytoEX

Thanks for the answer!

For hotkeys to work when OBS is not in-focus, you must enable the Accessibility permission for OBS.

Yes, I did that. By the way, the OBS team did a great job with the whole “Review App Permissions” workflow. It’s awesome! 👍

For the described "erratic" nature of hotkeys when OBS is in-focus, please provide one example hotkey combination

Control+Option+Command+A. (But really, as I mentioned, Control+Option+Command+ANY-KEY doesn’t work, I’m saying Control+Option+Command+A because you asked for one specific example 😬)

and specific steps to reproduce that we can test.

The usual workflow, really: Open OBS, create a scene, go to Settings > Hotkeys > SCENE > Switch to scene, assign a keyboard shortcut, “Apply”, press the keyboard shortcut, and OBS doesn’t switch to the scene as it should.

I can record a short video if you think that may help uncover something odd that I’m doing and not noticing.

I tried other keyboard shortcuts like Control+KEY and they work, so it seems to be related to the Control+Option+Command combination.

I thought that perhaps the key combinations I tried were clashing with another application, but I don’t think that’s the case for two reasons: 1. After having tried OBS, I bound the same key combination in Hammespoon and it worked; and 2. I tried a bunch of key combinations, and none of them worked in OBS: Control+Option+Command+{A,R,T,Y,F,G,H,J,K,V,B,N,M}.

Please test on OBS Studio 28.0.2 or newer, and preferably on macOS 12 (or latest stable).

I’m running OBS Studio 28.0.2 and macOS Monterey 12.6 (the latest stable).

gxalpha commented 2 years ago

Can confirm that Cmd, Ctl, and Alt seem to be mutually exclusive when in-focus. Out-of-focus, I couldn't find combinations that didn't work.

leafac commented 2 years ago

@gxalpha: Oh, yeah! You’re right!

The issue only occurs when the OBS window is in focus. When another window is in focus, the Control+Option+Command+ANY-KEY hotkeys do work! That’s even stranger to me… 🤷

I also played around with different options of Advanced > Hotkeys > Hotkey Focus Behavior, but that doesn’t seem to affect anything.

meneguzzi commented 2 years ago

Yeah, things seem to be working now. Should we close the issue then?

leafac commented 2 years ago

@meneguzzi:

Yeah, things seem to be working now. Should we close the issue then?

🤔 I don’t think so.

I think that keyboard shortcuts of the form Control+Option+Command+ANY-KEY should work when the OBS window is in focus. Or if there’s a reason why they shouldn’t work, I think that there should be some kind of warning on the interface to mention that and avoid confusion. (I’m thinking of a warning similar to what you see when you try to bind the same key combination to multiple actions. A little ⚠️ icon.)

PatTheMav commented 2 years ago

It could be that we need to disable InputMethods the same way we had to disable them for the shortcut configuration screen, as the default InputMethod will "eat" keystrokes that don't result in actual character output.

eadnams22 commented 1 year ago

Multiple hotkey fixes went into OBS Studio 28/28.0.2. For hotkeys to work when OBS is not in-focus, you must enable the Accessibility permission for OBS.

For the described "erratic" nature of hotkeys when OBS is in-focus, please provide one example hotkey combination and specific steps to reproduce that we can test. Please test on OBS Studio 28.0.2 or newer, and preferably on macOS 12 (or latest stable).

I have right arrow and numpad 5 set to ‘transition’ in studio mode, both will work maybe once, then stop working completely.

Running 28.1.2, macOS 12, M1 Pro

Have messed with permissions, and hotkey settings, no change in this behaviour. Works briefly again if I restart OBS, but can’t do that mid-event.

proactivematter commented 1 year ago

It's also a problem with SHIFT+CTRL+CMD and SHIFT+OPT+CMD when in focus.

SHIFT+CTRL+OPT does seem to work both in and out of focus per my testing.

Wish we could activate stuff directly through a CLI on M1-MAC, but as far as I know the CLI addon is only available for Windows/Linux - unless someone knows of another alternative?

PatTheMav commented 1 year ago

Alas I cannot reproduce either issue - I just tried using hotkey combinations of both <SHIFT+CTRL+CMD> as well as <SHIFT+OPT+CMD> and was able to switch scenes with OBS in focus as well as with Safari in focus.

thinksamwp commented 1 year ago

I have also experienced hotkeys stop working after having OBS open for a while. Once they stop working the only fix I have found is to relaunch the application. Mac OS 13.0.1, OBS Studio 28.0.3.

PatTheMav commented 1 year ago

As mentioned before, I'm not able to reproduce this. We would need more concrete reproduction steps:

We'd also need a more concrete value for "after a while".

Please also verify that if OBS is not in focus whether your chosen keystroke is not used by the application currently in focus.

thinksamwp commented 1 year ago

One way I have found to reproduce this is to bind M to Mute/Unmute on an audio source, then click the background of either the Scenes or the Sources dock (I have the docks embedded into the preview window). Doing this stops the hotkey from working until you click on the background of the preview window itself, which makes it work again.

PatTheMav commented 1 year ago

At first glance this looks like (another) issue with Qt's key event handling - when the source is selected, we never receive a "KeyPress" event (which we look for when triggering hotkeys) but only a "KeyRelease" event.

Weirdly enough, when OBS is not in focus, the hotkeys are injected by macOS' accessibility framework and then the <M> key mutes/unmutes the source (regardless of whether it's in focus or not).

macOS sends "NSEventKeyDown" to Qt, which then "ignores" it, so this could also be related to InputMethods just like when it interfered with setting the hotkeys. Will be a bit messy to figure out though.

Morialkar commented 1 year ago

I have a similar issue with macro keys on my keyboard where if I'm inside OBS I can use the macro key of my Logitech keyboard (created using Logi Options+) to trigger my hotkey to change scene (CMD+CTRL+SHIFT+OPT+[1-3]) but outside of OBS the hotkey doesn't get triggered.

This issue is not present if I input the hotkey (CMD+CTRL+SHIFT+OPT+[1-3]) manually on the keyboard, only from the macro key.

mattharrison commented 1 year ago

For others running into this issue, I needed to update my input monitoring settings.

System Preferences -> Security & Privacy -> Privacy (Tab) -> Input Monitoring (left side) -> add the application (OBS).

Works for me now mostly now in OBS 29. (Hyper-Y works, Hyper-N doesn't, ctr-shift-6 works).

See screenshot. Screen Shot 2023-03-09 at 3 43 19 PM

ariefiantofadli commented 1 year ago

Hi, I've solved with this hotkeys (with CTRL SHIFT 7 and next), running normal with the out-focus when using hotkeys (with keyboard, mx keys), but it not works when I'm using Macropad-VIA. It's normal when on-focus to OBS, but not works in out-focus only. Both are set in INPUT MONITORING permission, a few restart. Nothing changed.

So, it still not working when I'm using Macropad-VIA, only when out-focus, normal in on-focus to OBS.

Any suggestion? Thanks.

Mac 13.3.1 OBS 29.1.1 VIA 2.0.5

ttwthomas commented 1 year ago

I have a similar issue on m1 mac with latest obs 29.1.3 on macos 13.1 no hotkeys are working when obs is out of focus (tried Q, shit Q, ctrl + shift 7, f4, f13) hotkey focus behavior is set "to never disable hotkey" input monitoring is activated for obs i can do more test if needed

DanAlbrechtSFDC commented 1 year ago

Similar issue. It appears that the a hotkey will work 1 time but then will no other hotkeys will work. In my case I am using Downstream Keyer and trying to turn on and off. I have set the hotkeys in preferences and then setup a stream deck button to control the hotkey. If I press the hotkey on the keyboard while OBS is in focus, it works once. After that single press, no other hotkeys will work.

Mac OS 13.5 OBS 29.1.3

tech097 commented 12 months ago

So I'm adding my two cents to this because it's getting frustrating for me. In order to manage hotkeys for what I wanna do I have to cramp my fingers by hovering them over shift, command, z, x, c, and s. Because I am unable to just use 1, 2, 3, and 4 as hotkeys, the only feasible spot with a row of 3 keys that are not disabled because of a prior Mac Hotkey overwriting it are z, x, and c, and because my pinky and thumb are taken up by shift and command, I have to use my middle finger to hover between the middle key and the top key, making it much more inconvenient.

I'm sorry if I seem harsh I just would like to have the option to not compromise my physical comfort to stream.

macOS Ventura 13.5.2 OBS 29.1.3

alex-walton3 commented 11 months ago

This bug sucks. M2 Mac on Sonoma 14.1, OBS 30.0.0

william200mph commented 11 months ago

Hi, can confirm this is still an issue. OBS 30.0.0 Sonoma 14.1.2 Restart of OBS fixes. Any more info I can provide to help work toward a fix?

QuintenDockx commented 10 months ago

I was trying different things and what works for me is putting the hotkeys in as "option + hotkey". Don't know why this works but it seems to fix the problem for me. so instead of my numeric hotkeys 1, 2, 3,... I made the hotkeys option1, option2, option3,... (I don't have to press the option key to activate the hotkey, just the number)

Hopefully this is useful for someone :)

anasak-dev commented 9 months ago

after checking lot of options in my mac (m1) , looks like this one did the trick

Go to Privacy & Security => Accessibility => enable or add OBS to allow controlling your computer

Since applying above condition, my OBS hotkeys are working as expected as of now.

crysxd commented 8 months ago

I'm experiencing a similar issue. Even with Privacy & Security > Accessibility and Privacy & Security > Input Monitoring on my hotkeys stop working after a while. Usually it's good for 2-3h in a stream and then they stop working. Restarting OBS solves the issue temporarily, but that's not really an option during a live stream.

I use hotkeys to switch scenes and I recently added a "Shortcut" (from the macOS app) that the same hotkey also brings the corresponding application screenshared in that scene into focus. The issue was already occurring before this, but now after some time OBS stops switching the scene but the other Shortcut to bring the screenshared application in focus still works. So it seems like that other apps still receive the hotkey trigger, but OBS doesn't.

poporange630 commented 4 months ago

This issue is still present and affects my production pretty badly. Hotkey will fail randomly and those functions which can only be triggered by hot keys can not be summoned.

eadnams22 commented 4 months ago

Yeah, it started again after working for a bit. If I re-bind the hotkey, it will work exactly once before it stops.

RamiAwar commented 3 months ago

I'm experiencing a similar issue. Even with Privacy & Security > Accessibility and Privacy & Security > Input Monitoring on my hotkeys stop working after a while. Usually it's good for 2-3h in a stream and then they stop working. Restarting OBS solves the issue temporarily, but that's not really an option during a live stream.

I use hotkeys to switch scenes and I recently added a "Shortcut" (from the macOS app) that the same hotkey also brings the corresponding application screenshared in that scene into focus. The issue was already occurring before this, but now after some time OBS stops switching the scene but the other Shortcut to bring the screenshared application in focus still works. So it seems like that other apps still receive the hotkey trigger, but OBS doesn't.

Thanks @crysxd! That worked for me as well.

jcm93 commented 2 months ago

I believe that https://github.com/obsproject/obs-studio/pull/11100 likely fixes this issue. The fact that it was linked to this issue caused it to automatically be closed. I would encourage people in this thread that are interested to test nightly or PR builds with the fix (or the next beta etc) and report here if they're still encountering any erratic or inconsistent hotkey behavior.