kasper / phoenix

A lightweight macOS window and app manager scriptable with JavaScript
https://kasper.github.io/phoenix/
Other
4.38k stars 127 forks source link

Crash after connecting usb-c screen #231

Closed kidk closed 5 years ago

kidk commented 5 years ago

Every time I disconnect and reconnect my USB-C screen phoenix crashes and I need to restart it. I opened it through the command line to get the logs and this is what I got. Let me know if you need any other info. I'm using git@github.com:fabiospampinato/phoenix.git (unmodified) as a script.

Stacktrace

2018-11-28 13:38:27.905 Phoenix[50812:1354463] Context loaded.
2018-11-28 13:38:31.749 Phoenix[50812:1354463] Error: Could not get process identifier for accessibility element <AXUIElement System Wide 0x7fc5c7910130>. (-25202)
2018-11-28 14:42:44.893 Phoenix[50812:1354463] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff3db9fe65 __exceptionPreprocess + 256
    1   libobjc.A.dylib                     0x00007fff69bf6720 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff3dbdf458 -[CFPrefsConfigurationFileSource initWithConfigurationPropertyList:containingPreferences:] + 0
    3   CoreFoundation                      0x00007fff3dab10ee -[__NSPlaceholderArray initWithObjects:count:] + 230
    4   CoreFoundation                      0x00007fff3db1e99c +[NSArray arrayWithObjects:count:] + 52
    5   Phoenix                             0x000000010bc66075 -[PHSpace screens] + 620
    6   CoreFoundation                      0x00007fff3daf7cdc __invoking___ + 140
    7   CoreFoundation                      0x00007fff3daf7bab -[NSInvocation invoke] + 311
    8   JavaScriptCore                      0x00007fff41144e98 _ZN3JSC24ObjCCallbackFunctionImpl4callEP9JSContextP13OpaqueJSValuemPKPKS3_PS6_ + 440
    9   JavaScriptCore                      0x00007fff411448cc _ZN3JSCL34objCCallbackFunctionCallAsFunctionEPK15OpaqueJSContextP13OpaqueJSValueS4_mPKPKS3_PS6_ + 236
    10  JavaScriptCore                      0x00007fff4114419c _ZN3JSC19APICallbackFunction4callINS_20ObjCCallbackFunctionEEExPNS_9ExecStateE + 492
    11  ???                                 0x0000536c7840102d 0x0 + 91725339037741
    12  JavaScriptCore                      0x00007fff41133672 llint_entry + 26726
    13  JavaScriptCore                      0x00007fff411336cd llint_entry + 26817
    14  JavaScriptCore                      0x00007fff41133672 llint_entry + 26726
    15  JavaScriptCore                      0x00007fff41133672 llint_entry + 26726
    16  JavaScriptCore                      0x00007fff41133672 llint_entry + 26726
    17  JavaScriptCore                      0x00007fff4112cc8e vmEntryToJavaScript + 244
    18  JavaScriptCore                      0x00007fff40f56ac6 _ZN3JSC11Interpreter11executeCallEPNS_9ExecStateEPNS_8JSObjectENS_8CallTypeERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 470
    19  JavaScriptCore                      0x00007fff4197e3f4 _ZN3JSC12profiledCallEPNS_9ExecStateENS_15ProfilingReasonENS_7JSValueENS_8CallTypeERKNS_8CallDataES3_RKNS_7ArgListE + 196
    20  JavaScriptCore                      0x00007fff40f56774 JSObjectCallAsFunction + 468
    21  JavaScriptCore                      0x00007fff410bc603 -[JSValue callWithArguments:] + 291
    22  Phoenix                             0x000000010bc6282f -[PHHandler callWithArguments:] + 126
    23  Phoenix                             0x000000010bc62d58 -[PHEventHandler didReceiveNotification:] + 595
    24  CoreFoundation                      0x00007fff3db4c3f2 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
    25  CoreFoundation                      0x00007fff3db4c36c ___CFXRegistrationPost_block_invoke + 63
    26  CoreFoundation                      0x00007fff3db4c28d _CFXRegistrationPost + 398
    27  CoreFoundation                      0x00007fff3db546d9 ___CFXNotificationPost_block_invoke + 87
    28  CoreFoundation                      0x00007fff3dabbe8a -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1633
    29  CoreFoundation                      0x00007fff3dabb24d _CFXNotificationPost + 742
    30  Foundation                          0x00007fff3fe4398b -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
    31  AppKit                              0x00007fff3b40c677 spacesNotificationHandler + 119
    32  SkyLight                            0x00007fff63b90869 _ZN12_GLOBAL__N_123notify_datagram_handlerEj15CGSDatagramTypePvmS1_ + 629
    33  SkyLight                            0x00007fff63b94324 _ZN21CGSDatagramReadStream33dispatch_next_main_queue_datagramEv + 270
    34  SkyLight                            0x00007fff63de802e ___ZN21CGSDatagramReadStream35dispatch_main_queue_datagrams_asyncEP16dispatch_queue_sPS__block_invoke + 59
    35  libdispatch.dylib                   0x00007fff6ac75d53 _dispatch_call_block_and_release + 12
    36  libdispatch.dylib                   0x00007fff6ac76dcf _dispatch_client_callout + 8
    37  libdispatch.dylib                   0x00007fff6ac81f63 _dispatch_main_queue_callback_4CF + 1125
    38  CoreFoundation                      0x00007fff3dae8e8b __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    39  CoreFoundation                      0x00007fff3dae859a __CFRunLoopRun + 2335
    40  CoreFoundation                      0x00007fff3dae7a28 CFRunLoopRunSpecific + 463
    41  HIToolbox                           0x00007fff3cd80b35 RunCurrentEventLoopInMode + 293
    42  HIToolbox                           0x00007fff3cd80774 ReceiveNextEventCommon + 371
    43  HIToolbox                           0x00007fff3cd805e8 _BlockUntilNextEventMatchingListInModeWithFilter + 64
    44  AppKit                              0x00007fff3b03ceb7 _DPSNextEvent + 997
    45  AppKit                              0x00007fff3b03bc56 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1362
    46  AppKit                              0x00007fff3b035cb9 -[NSApplication run] + 699
    47  AppKit                              0x00007fff3b0253f7 NSApplicationMain + 780
    48  libdyld.dylib                       0x00007fff6acc508d start + 1
    49  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
[1]    50812 abort      /Applications/Phoenix.app/Contents/MacOS/Phoenix
kasper commented 5 years ago

@kidk Thanks for reporting and sorry for the trouble! Looks like it might be related to Spaces, which is unfortunately using a private API. I’ll look into how to fix this.

kidk commented 5 years ago

@kasper No worries. Thank you for the great project.

kasper commented 5 years ago

@kidk Thanks, I really appreciate it! Just for some more context, do you have a callback on the screen event?

kidk commented 5 years ago

@kasper Do you mean on 'screensDidChange' event?

I'm using fabiospampinato/phoenix and it seems it's not using screensDidChange: https://github.com/fabiospampinato/phoenix/search?q=screensDidChange&unscoped_q=screensDidChange

It is using the spaceDidChange event: https://github.com/fabiospampinato/phoenix/search?q=spaceDidChange&unscoped_q=spaceDidChange

kasper commented 5 years ago

@kidk Good old attempt of trying to add nil to an array. I guess this is a very time sensitive issue. This should now (hopefully) be fixed in build 78. Thanks for reporting!

kidk commented 5 years ago

Thanks for the fix 🎉