2

After replacing Big Sur MacOS 11.0 with the latest 11.5 update, my app's AXObserverAddNotification method fails despite providing both observer and element. Below is the ObjC code I use:

if (AXObserverCreate(pid, menuOpened, &observer) == kAXErrorSuccess) {
            
CFRunLoopAddSource(CFRunLoopGetCurrent(),
                               AXObserverGetRunLoopSource(observer),
                               kCFRunLoopDefaultMode);

AXUIElementRef element = AXUIElementCreateApplication(pid);
            
NSLog(@"observer: %@   element: %@", observer, observer);
            
if(AXObserverAddNotification(observer, element, kAXMenuOpenedNotification, (__bridge void *)(self)) != kAXErrorSuccess) {
                
    NSLog(@"Failed to create observer for application \"%@\". pid: %i", self.activeApp, pid);
}

}

Here is the log window output showing that the AXObserverAddNotification method "Failed to create observer" for a newly the newly launched app--in this case, "System Preferences":

2021-08-11 10:59:52.682012-0700 SpellSentry[98563:3551301] observer: <AXObserver 0x6000032d21c0> {pid=98580} element: <AXObserver 0x6000032d21c0> {pid=98580} 2021-08-11 10:59:52.695445-0700 SpellSentry[98563:3551301] Failed to create observer for application "System Preferences". pid: 98580

I never experienced this bug in MacOS 11.0 and suspect that the newer OS contains added security measures that are interfering with the proper functioning of the Carbon layer (the "Accessibility" programming layer). Perhaps others are having the same problem with OSX 11.5? Or is it me?

Antony
  • 41
  • 4

0 Answers0