libobs: Fix macOS 10.15 hotkey crash (temporary)

On 10.15, if a user activates secure input of some sort, the hotkey code
will begin to crash inside of any Apple function related to hotkeys,
even after secure input has ended.  This does not appear to be the fault
of OBS; the reason to this is still as of yet unknown, but is suspected
to be a bug inside of Apple code that's a new regression as of 10.15.

So for the time being as a temporary solution to the crash, simply
disable external hotkey support once secure input has been detected.

Because of this issue, the hotkey code should probably be replaced by a
different method of tracking hotkeys, perhaps InstallEventHandler for
example.  This commit is little more than a bandaid to the crash.
This commit is contained in:
jp9000 2020-03-31 10:31:11 -07:00
parent b9f7702378
commit d002345a11

View file

@ -175,6 +175,8 @@ static void log_os_name(id pi, SEL UTF8StringSel)
blog(LOG_INFO, "OS Name: %s", name ? name : "Unknown");
}
static bool using_10_15_or_above = true;
static void log_os_version(id pi, SEL UTF8StringSel)
{
typedef id (*version_func)(id, SEL);
@ -186,6 +188,16 @@ static void log_os_version(id pi, SEL UTF8StringSel)
const char *version = UTF8String(vs, UTF8StringSel);
blog(LOG_INFO, "OS Version: %s", version ? version : "Unknown");
if (version) {
int major;
int minor;
int count = sscanf(version, "Version %d.%d", &major, &minor);
if (count == 2 && major == 10) {
using_10_15_or_above = minor >= 15;
}
}
}
static void log_os(void)
@ -239,6 +251,7 @@ static bool dstr_from_cfstring(struct dstr *str, CFStringRef ref)
struct obs_hotkeys_platform {
volatile long refs;
bool secure_input_activated;
TISInputSourceRef tis;
CFDataRef layout_data;
UCKeyboardLayout *layout;
@ -1749,6 +1762,14 @@ bool obs_hotkeys_platform_is_pressed(obs_hotkeys_platform_t *plat,
if (key >= OBS_KEY_LAST_VALUE)
return false;
/* if secure input is activated, kill hotkeys.
*
* TODO: rewrite all mac hotkey code, suspect there's a bug in 10.15
* causing the crash internally. */
if (plat->secure_input_activated) {
return false;
}
for (size_t i = 0; i < plat->keys[key].num;) {
IOHIDElementRef element = plat->keys[key].array[i];
IOHIDValueRef value = 0;
@ -1758,6 +1779,11 @@ bool obs_hotkeys_platform_is_pressed(obs_hotkeys_platform_t *plat,
continue;
}
if (using_10_15_or_above && IsSecureEventInputEnabled()) {
plat->secure_input_activated = true;
return false;
}
if (IOHIDDeviceGetValue(device, element, &value) !=
kIOReturnSuccess) {
i += 1;