arttuperala / kmbmpdc

kawaii menu bar music player daemon controller
https://kmbmpdc.perala.me
Apache License 2.0
47 stars 6 forks source link

App crashes on fast song switching #11

Open muffinmad opened 6 years ago

muffinmad commented 6 years ago

Rapidly pressing next/previuous button (media keys or popup window buttons) causes app to crash.

arttuperala commented 6 years ago

I believe this is because the way how the application currently communicates with MPD is just outright bad. I'm currently working on fixing it to the way it should have been from the start and I imagine that'll fix this issue.

arttuperala commented 6 years ago

https://meido.perala.me/kmbmpdc

You can try the latest development build to see if the new event loop fixes this issue. At least it's been fine in my testing.

muffinmad commented 6 years ago

Thanks! But this version also crashes.

Process:               kmbmpdc [54659]
Path:                  /private/var/folders/*/kmbmpdc.app/Contents/MacOS/kmbmpdc
Identifier:            me.perala.kmbmpdc
Version:               2.0.1 (109)

Crashed Thread:        7  Dispatch queue: com.apple.NSFileHandle.fd_monitoring

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000020
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [0]

VM Regions Near 0x20:
--> 
    __TEXT                 00000001012db000-0000000101305000 [  168K] r-x/rwx SM=COW  V
 [/var/folders/wj/cm4p5xs17jzf6f8bs46tslyc0000gn/T/AppTranslocation/380842BD-CAF3-4313-893A-7636C2E0D9FC/d/kmbmpdc.app/Contents/MacOS/kmbmpdc]

Thread 0:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff5202120a mach_msg_trap + 10
1   libsystem_kernel.dylib          0x00007fff52020724 mach_msg + 60
2   com.apple.CoreFoundation        0x00007fff29bc17d5 __CFRunLoopServiceMachPort + 341
3   com.apple.CoreFoundation        0x00007fff29bc0b27 __CFRunLoopRun + 1783
4   com.apple.CoreFoundation        0x00007fff29bc01a3 CFRunLoopRunSpecific + 483
5   com.apple.HIToolbox             0x00007fff28ea8d96 RunCurrentEventLoopInMode + 286
6   com.apple.HIToolbox             0x00007fff28ea8b06 ReceiveNextEventCommon + 613
7   com.apple.HIToolbox             0x00007fff28ea8884 _BlockUntilNextEventMatchingListInModeWithFilter + 64
8   com.apple.AppKit                0x00007fff2715ba73 _DPSNextEvent + 2085
9   com.apple.AppKit                0x00007fff278f1e34 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3044
10  com.apple.AppKit                0x00007fff27150885 -[NSApplication run] + 764
11  com.apple.AppKit                0x00007fff2711fa72 NSApplicationMain + 804
12  me.perala.kmbmpdc               0x00000001012de5a9 main + 9
13  libdyld.dylib                   0x00007fff51eda015 start + 1

Thread 1:
0   libsystem_kernel.dylib          0x00007fff5202b292 __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff521f220e _pthread_wqthread + 1552
2   libsystem_pthread.dylib         0x00007fff521f1be9 start_wqthread + 13

Thread 2:
0   libsystem_kernel.dylib          0x00007fff5202b292 __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff521f220e _pthread_wqthread + 1552
2   libsystem_pthread.dylib         0x00007fff521f1be9 start_wqthread + 13

Thread 3:: Dispatch queue: MediaKeyTap Runloop
0   libsystem_kernel.dylib          0x00007fff5202120a mach_msg_trap + 10
1   libsystem_kernel.dylib          0x00007fff52020724 mach_msg + 60
2   com.apple.CoreFoundation        0x00007fff29bc17d5 __CFRunLoopServiceMachPort + 341
3   com.apple.CoreFoundation        0x00007fff29bc0b27 __CFRunLoopRun + 1783
4   com.apple.CoreFoundation        0x00007fff29bc01a3 CFRunLoopRunSpecific + 483
5   com.apple.CoreFoundation        0x00007fff29bfec33 CFRunLoopRun + 99
6   nhurden.MediaKeyTap             0x00000001013600c2 partial apply for closure #1 in MediaKeyTapInternals.startKeyEventTap(callback:restart:) + 50
7   nhurden.MediaKeyTap             0x000000010135eef0 thunk for @callee_owned () -> () + 32
8   libdispatch.dylib               0x00007fff51ea864a _dispatch_call_block_and_release + 12
9   libdispatch.dylib               0x00007fff51ea0e08 _dispatch_client_callout + 8
10  libdispatch.dylib               0x00007fff51eb5267 _dispatch_queue_serial_drain + 635
11  libdispatch.dylib               0x00007fff51ea81b6 _dispatch_queue_invoke + 373
12  libdispatch.dylib               0x00007fff51eb5f5d _dispatch_root_queue_drain_deferred_wlh + 332
13  libdispatch.dylib               0x00007fff51eb9d71 _dispatch_workloop_worker_thread + 880
14  libsystem_pthread.dylib         0x00007fff521f1fd2 _pthread_wqthread + 980
15  libsystem_pthread.dylib         0x00007fff521f1be9 start_wqthread + 13

Thread 4:
0   libsystem_kernel.dylib          0x00007fff5202b292 __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff521f220e _pthread_wqthread + 1552
2   libsystem_pthread.dylib         0x00007fff521f1be9 start_wqthread + 13

Thread 5:: com.apple.NSEventThread
0   libsystem_kernel.dylib          0x00007fff5202120a mach_msg_trap + 10
1   libsystem_kernel.dylib          0x00007fff52020724 mach_msg + 60
2   com.apple.CoreFoundation        0x00007fff29bc17d5 __CFRunLoopServiceMachPort + 341
3   com.apple.CoreFoundation        0x00007fff29bc0b27 __CFRunLoopRun + 1783
4   com.apple.CoreFoundation        0x00007fff29bc01a3 CFRunLoopRunSpecific + 483
5   com.apple.AppKit                0x00007fff27298fc4 _NSEventThread + 184
6   libsystem_pthread.dylib         0x00007fff521f2661 _pthread_body + 340
7   libsystem_pthread.dylib         0x00007fff521f250d _pthread_start + 377
8   libsystem_pthread.dylib         0x00007fff521f1bf9 thread_start + 13

Thread 6:
0   libsystem_kernel.dylib          0x00007fff5202b292 __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff521f220e _pthread_wqthread + 1552
2   libsystem_pthread.dylib         0x00007fff521f1be9 start_wqthread + 13

Thread 7 Crashed:: Dispatch queue: com.apple.NSFileHandle.fd_monitoring
0   me.perala.kmbmpdc               0x00000001012fb144 mpd_status_get_song_pos + 4
1   me.perala.kmbmpdc               0x00000001012e2980 MPDClient.reloadQueue() + 640
2   me.perala.kmbmpdc               0x00000001012e217a MPDClient.reloadPlayerStatus() + 554
3   me.perala.kmbmpdc               0x00000001012e1a87 MPDClient.handleIdleEvent(socket:) + 119
4   me.perala.kmbmpdc               0x00000001012e5851 partial apply + 17
5   me.perala.kmbmpdc               0x00000001012e172f thunk for @callee_owned (@owned FileHandle) -> () + 47
6   com.apple.Foundation            0x00007fff2bdd4448 __33-[NSConcreteFileHandle _monitor:]_block_invoke + 50
7   libdispatch.dylib               0x00007fff51ea0e08 _dispatch_client_callout + 8
8   libdispatch.dylib               0x00007fff51eb3ed1 _dispatch_continuation_pop + 472
9   libdispatch.dylib               0x00007fff51ea30d1 _dispatch_source_invoke + 620
10  libdispatch.dylib               0x00007fff51eb50ca _dispatch_queue_serial_drain + 222
11  libdispatch.dylib               0x00007fff51ea81b6 _dispatch_queue_invoke + 373
12  libdispatch.dylib               0x00007fff51eb5f5d _dispatch_root_queue_drain_deferred_wlh + 332
13  libdispatch.dylib               0x00007fff51eb9d71 _dispatch_workloop_worker_thread + 880
14  libsystem_pthread.dylib         0x00007fff521f1fd2 _pthread_wqthread + 980
15  libsystem_pthread.dylib         0x00007fff521f1be9 start_wqthread + 13

Thread 8:
0   libsystem_pthread.dylib         0x00007fff521f1bdc start_wqthread + 0

Thread 9:
0   libsystem_kernel.dylib          0x00007fff5202b292 __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff521f2009 _pthread_wqthread + 1035
2   libsystem_pthread.dylib         0x00007fff521f1be9 start_wqthread + 13

Thread 10:
0   libsystem_pthread.dylib         0x00007fff521f1bdc start_wqthread + 0

Thread 7 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x0000000000000000  rcx: 0x0000000000000000  rdx: 0x00000000000ed110
  rdi: 0x0000000000000000  rsi: 0x0000000101e7da00  rbp: 0x000070000a76a4b0  rsp: 0x000070000a76a4b0
   r8: 0x0000000000000030   r9: 0x0000000000000000  r10: 0x000007fc15d704af  r11: 0x0000000000000031
  r12: 0x0000600000539000  r13: 0xc000000000000001  r14: 0x000060400009f8b0  r15: 0x0000000000000b5f
  rip: 0x00000001012fb144  rfl: 0x0000000000010202  cr2: 0x0000000000000020
arttuperala commented 6 years ago

I'll have to keep working at it. I think I've managed to get the error handling to a level where it no longer crashes. However, it'll freeze for a bit before it disconnects if commands are spammed. I think I need to work on the UI to somehow limit the spam in order to avoid the freezing.