tmandry / Swindler

macOS window management library for Swift
https://tmandry.github.io/Swindler/docs/main/
MIT License
695 stars 66 forks source link

<Notice>: Could not watch application com.google.Chrome (pid=464): invalidObject(AXError.APIDisabled) #9

Closed stphivos closed 7 years ago

stphivos commented 7 years ago

I tried adding my Cocoa Application - that has the Swindler binary embedded - to Preferences -> Security & Privacy -> Accessibility but this keeps happening. Any ideas?

tmandry commented 7 years ago

Try using the AXSwift API to check if your process is actually trusted.. if not, it will tell you what application to add.

From SwindlerExample:

        guard AXSwift.checkIsProcessTrusted(prompt: true) else {
            print("Not trusted as an AX process; please authorize and re-launch")
            NSApp.terminate(self)
            return
        }
stphivos commented 7 years ago

Thanks @tmandry. That prompted me to add the correct instance of my test app to the list of the allowed apps.

Now I'm getting different error(s): AXError.NotificationUnsupported and that it could not watch some applications:

2017-09-17 00:32:28.906711+0300 TestProject[4511:167914] Initializing Swindler
Sep 17 00:32:28  TestProject[4511] <Debug>: Initializing Swindler
2017-09-17 00:32:28.936484+0300 TestProject[4511:167914] Could not watch application WhatsApp-Helper (pid=3970): timeout(-1.0)
Sep 17 00:32:28  TestProject[4511] <Notice>: Could not watch application WhatsApp-Helper (pid=3970): timeout(-1.0)
2017-09-17 00:32:28.936800+0300 TestProject[4511:167914] Could not watch application WhatsApp-Helper (pid=3970): timeout(-1.0)
Sep 17 00:32:28  TestProject[4511] <Notice>: Could not watch application WhatsApp-Helper (pid=3970): timeout(-1.0)
2017-09-17 00:32:28.937284+0300 TestProject[4511:167914] Could not watch application WhatsApp-Helper (pid=3970): timeout(-1.0)
Sep 17 00:32:28  TestProject[4511] <Notice>: Could not watch application WhatsApp-Helper (pid=3970): timeout(-1.0)
2017-09-17 00:32:28.937632+0300 TestProject[4511:167914] Could not watch application WhatsApp-Helper (pid=3970): timeout(-1.0)
Sep 17 00:32:28  TestProject[4511] <Notice>: Could not watch application WhatsApp-Helper (pid=3970): timeout(-1.0)
2017-09-17 00:32:28.938042+0300 TestProject[4511:167914] Caught error: timeout(-1.0)
Sep 17 00:32:28  TestProject[4511] <Error>: Caught error: timeout(-1.0)
2017-09-17 00:32:28.938083+0300 TestProject[4511:167914] Done initializing
Sep 17 00:32:28  TestProject[4511] <Debug>: Done initializing
2017-09-17 00:32:28.943256+0300 TestProject[4511:167914] Application invalidated: com.apple.dock
Sep 17 00:32:29  TestProject[4511] <Debug>: Application invalidated: com.apple.dock
2017-09-17 00:32:29.028523+0300 TestProject[4511:167914] Window <AXWindow "Window" (pid=365)> has subrole AXUnknown, unwatching
Sep 17 00:32:29  TestProject[4511] <Debug>: Window <AXWindow "Window" (pid=365)> has subrole AXUnknown, unwatching
2017-09-17 00:32:29.029330+0300 TestProject[4511:167914] Window <AXUnknown "<AXUIElement 0x610000054eb0> {pid=464}" (pid=464)> has subrole AXUnknown, unwatching
Sep 17 00:32:29  TestProject[4511] <Debug>: Window <AXUnknown "<AXUIElement 0x610000054eb0> {pid=464}" (pid=464)> has subrole AXUnknown, unwatching
2017-09-17 00:32:29.031089+0300 TestProject[4511:167914] Application invalidated: com.apple.dock
Sep 17 00:32:29  TestProject[4511] <Debug>: Application invalidated: com.apple.dock
2017-09-17 00:32:29.032461+0300 TestProject[4511:167914] Couldn't initialize window for element <AXWindow "Window" (pid=365)> () of com.apogee.ApogeePopup: windowIgnored(<AXWindow "Window" (pid=365)>)
Sep 17 00:32:29  TestProject[4511] <Debug>: Couldn't initialize window for element <AXWindow "Window" (pid=365)> () of com.apogee.ApogeePopup: windowIgnored(<AXWindow "Window" (pid=365)>)
2017-09-17 00:32:29.034312+0300 TestProject[4511:167914] Couldn't initialize window for element <AXUnknown "<AXUIElement 0x610000054eb0> {pid=464}" (pid=464)> () of com.google.Chrome: windowIgnored(<AXUnknown "<AXUIElement 0x610000054eb0> {pid=464}" (pid=464)>)
Sep 17 00:32:29  TestProject[4511] <Debug>: Couldn't initialize window for element <AXUnknown "<AXUIElement 0x610000054eb0> {pid=464}" (pid=464)> () of com.google.Chrome: windowIgnored(<AXUnknown "<AXUIElement 0x610000054eb0> {pid=464}" (pid=464)>)
2017-09-17 00:32:29.036660+0300 TestProject[4511:167914] Application invalidated: com.apple.dock
Sep 17 00:32:29  TestProject[4511] <Debug>: Application invalidated: com.apple.dock
2017-09-17 00:32:29.039667+0300 TestProject[4511:167914] Application invalidated: com.apple.dock
Sep 17 00:32:29  TestProject[4511] <Debug>: Application invalidated: com.apple.dock
2017-09-17 00:32:29.041369+0300 TestProject[4511:167914] Could not watch application com.apple.dock (pid=308): invalidObject(AXError.NotificationUnsupported)
Sep 17 00:32:29  TestProject[4511] <Notice>: Could not watch application com.apple.dock (pid=308): invalidObject(AXError.NotificationUnsupported)
2017-09-17 00:32:29.042168+0300 TestProject[4511:167914] Could not watch application com.apple.dock (pid=308): invalidObject(AXError.NotificationUnsupported)
Sep 17 00:32:29  TestProject[4511] <Notice>: Could not watch application com.apple.dock (pid=308): invalidObject(AXError.NotificationUnsupported)
2017-09-17 00:32:29.043691+0300 TestProject[4511:167914] Couldn't initialize window for element <AXScrollArea "<AXUIElement 0x61800004ed90> {pid=312}" (pid=312)> (desktop) of com.apple.finder: AXError.NotificationUnsupported
Sep 17 00:32:29  TestProject[4511] <Debug>: Couldn't initialize window for element <AXScrollArea "<AXUIElement 0x61800004ed90> {pid=312}" (pid=312)> (desktop) of com.apple.finder: AXError.NotificationUnsupported
2017-09-17 00:32:29.044155+0300 TestProject[4511:167914] Could not watch application com.apple.dock (pid=308): invalidObject(AXError.NotificationUnsupported)
Sep 17 00:32:29  TestProject[4511] <Notice>: Could not watch application com.apple.dock (pid=308): invalidObject(AXError.NotificationUnsupported)
2017-09-17 00:32:29.044611+0300 TestProject[4511:167914] Could not watch application com.apple.dock (pid=308): invalidObject(AXError.NotificationUnsupported)
Sep 17 00:32:29  TestProject[4511] <Notice>: Could not watch application com.apple.dock (pid=308): invalidObject(AXError.NotificationUnsupported)
2017-09-17 00:32:31.103916+0300 TestProject[4511:167914] PromiseKit: unhandled error: Error Domain=Swindler.PropertyError Code=0 "(null)"
2017-09-17 00:32:31.104075+0300 TestProject[4511:167914] PromiseKit: unhandled error: Error Domain=Swindler.PropertyError Code=0 "(null)"

I'm using $ xcrun swift -version

Apple Swift version 3.1 (swiftlang-802.0.53 clang-802.0.42)
Target: x86_64-apple-macosx10.9

and Xcode Version 8.3.3 (8E3004b).

tmandry commented 7 years ago

Those look expected to me. Many helper or otherwise "special" app components don't respond to the AX requests or respond with an error. Currently I log them because it's hard to determine if an app "should" fail (especially on timeouts). This needs to be documented, though.

On Sat, Sep 16, 2017, 4:44 PM Phivos Stylianides notifications@github.com wrote:

Thanks @tmandry https://github.com/tmandry. That prompted me to add the correct instance of my test app to the list of the allowed apps.

Now I'm getting different error(s): AXError.NotificationUnsupported and that it could not watch some applications:

2017-09-17 00:32:28.906711+0300 TestProject[4511:167914] Initializing Swindler Sep 17 00:32:28 TestProject[4511] : Initializing Swindler 2017-09-17 00:32:28.936484+0300 TestProject[4511:167914] Could not watch application WhatsApp-Helper (pid=3970): timeout(-1.0) Sep 17 00:32:28 TestProject[4511] : Could not watch application WhatsApp-Helper (pid=3970): timeout(-1.0) 2017-09-17 00:32:28.936800+0300 TestProject[4511:167914] Could not watch application WhatsApp-Helper (pid=3970): timeout(-1.0) Sep 17 00:32:28 TestProject[4511] : Could not watch application WhatsApp-Helper (pid=3970): timeout(-1.0) 2017-09-17 00:32:28.937284+0300 TestProject[4511:167914] Could not watch application WhatsApp-Helper (pid=3970): timeout(-1.0) Sep 17 00:32:28 TestProject[4511] : Could not watch application WhatsApp-Helper (pid=3970): timeout(-1.0) 2017-09-17 00:32:28.937632+0300 TestProject[4511:167914] Could not watch application WhatsApp-Helper (pid=3970): timeout(-1.0) Sep 17 00:32:28 TestProject[4511] : Could not watch application WhatsApp-Helper (pid=3970): timeout(-1.0) 2017-09-17 00:32:28.938042+0300 TestProject[4511:167914] Caught error: timeout(-1.0) Sep 17 00:32:28 TestProject[4511] : Caught error: timeout(-1.0) 2017-09-17 00:32:28.938083+0300 TestProject[4511:167914] Done initializing Sep 17 00:32:28 TestProject[4511] : Done initializing 2017-09-17 00:32:28.943256+0300 TestProject[4511:167914] Application invalidated: com.apple.dock Sep 17 00:32:29 TestProject[4511] : Application invalidated: com.apple.dock 2017-09-17 00:32:29.028523+0300 TestProject[4511:167914] Window <AXWindow "Window" (pid=365)> has subrole AXUnknown, unwatching Sep 17 00:32:29 TestProject[4511] : Window <AXWindow "Window" (pid=365)> has subrole AXUnknown, unwatching 2017-09-17 00:32:29.029330+0300 TestProject[4511:167914] Window <AXUnknown "<AXUIElement 0x610000054eb0> {pid=464}" (pid=464)> has subrole AXUnknown, unwatching Sep 17 00:32:29 TestProject[4511] : Window <AXUnknown "<AXUIElement 0x610000054eb0> {pid=464}" (pid=464)> has subrole AXUnknown, unwatching 2017-09-17 00:32:29.031089+0300 TestProject[4511:167914] Application invalidated: com.apple.dock Sep 17 00:32:29 TestProject[4511] : Application invalidated: com.apple.dock 2017-09-17 00:32:29.032461+0300 TestProject[4511:167914] Couldn't initialize window for element <AXWindow "Window" (pid=365)> () of com.apogee.ApogeePopup: windowIgnored(<AXWindow "Window" (pid=365)>) Sep 17 00:32:29 TestProject[4511] : Couldn't initialize window for element <AXWindow "Window" (pid=365)> () of com.apogee.ApogeePopup: windowIgnored(<AXWindow "Window" (pid=365)>) 2017-09-17 00:32:29.034312+0300 TestProject[4511:167914] Couldn't initialize window for element <AXUnknown "<AXUIElement 0x610000054eb0> {pid=464}" (pid=464)> () of com.google.Chrome: windowIgnored(<AXUnknown "<AXUIElement 0x610000054eb0> {pid=464}" (pid=464)>) Sep 17 00:32:29 TestProject[4511] : Couldn't initialize window for element <AXUnknown "<AXUIElement 0x610000054eb0> {pid=464}" (pid=464)> () of com.google.Chrome: windowIgnored(<AXUnknown "<AXUIElement 0x610000054eb0> {pid=464}" (pid=464)>) 2017-09-17 00:32:29.036660+0300 TestProject[4511:167914] Application invalidated: com.apple.dock Sep 17 00:32:29 TestProject[4511] : Application invalidated: com.apple.dock 2017-09-17 00:32:29.039667+0300 TestProject[4511:167914] Application invalidated: com.apple.dock Sep 17 00:32:29 TestProject[4511] : Application invalidated: com.apple.dock 2017-09-17 00:32:29.041369+0300 TestProject[4511:167914] Could not watch application com.apple.dock (pid=308): invalidObject(AXError.NotificationUnsupported) Sep 17 00:32:29 TestProject[4511] : Could not watch application com.apple.dock (pid=308): invalidObject(AXError.NotificationUnsupported) 2017-09-17 00:32:29.042168+0300 TestProject[4511:167914] Could not watch application com.apple.dock (pid=308): invalidObject(AXError.NotificationUnsupported) Sep 17 00:32:29 TestProject[4511] : Could not watch application com.apple.dock (pid=308): invalidObject(AXError.NotificationUnsupported) 2017-09-17 00:32:29.043691+0300 TestProject[4511:167914] Couldn't initialize window for element <AXScrollArea "<AXUIElement 0x61800004ed90> {pid=312}" (pid=312)> (desktop) of com.apple.finder: AXError.NotificationUnsupported Sep 17 00:32:29 TestProject[4511] : Couldn't initialize window for element <AXScrollArea "<AXUIElement 0x61800004ed90> {pid=312}" (pid=312)> (desktop) of com.apple.finder: AXError.NotificationUnsupported 2017-09-17 00:32:29.044155+0300 TestProject[4511:167914] Could not watch application com.apple.dock (pid=308): invalidObject(AXError.NotificationUnsupported) Sep 17 00:32:29 TestProject[4511] : Could not watch application com.apple.dock (pid=308): invalidObject(AXError.NotificationUnsupported) 2017-09-17 00:32:29.044611+0300 TestProject[4511:167914] Could not watch application com.apple.dock (pid=308): invalidObject(AXError.NotificationUnsupported) Sep 17 00:32:29 TestProject[4511] : Could not watch application com.apple.dock (pid=308): invalidObject(AXError.NotificationUnsupported) 2017-09-17 00:32:31.103916+0300 TestProject[4511:167914] PromiseKit: unhandled error: Error Domain=Swindler.PropertyError Code=0 "(null)" 2017-09-17 00:32:31.104075+0300 TestProject[4511:167914] PromiseKit: unhandled error: Error Domain=Swindler.PropertyError Code=0 "(null)"

I'm using $ xcrun swift -version

Apple Swift version 3.1 (swiftlang-802.0.53 clang-802.0.42) Target: x86_64-apple-macosx10.9

and Xcode Version 8.3.3 (8E3004b).

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/tmandry/Swindler/issues/9#issuecomment-329996720, or mute the thread https://github.com/notifications/unsubscribe-auth/ACLMYBDp5IUDIQhmdwf-MrGHbeid_9Keks5sjEFLgaJpZM4PZ6Yx .

stphivos commented 7 years ago

Ok i'm now ignoring those and the rest work as expected, thanks.

tmandry commented 7 years ago

Added these topics to the README.