albertz / music-player

Music player - endlessly plays your music
http://albertz.github.io/music-player/
BSD 2-Clause "Simplified" License
492 stars 59 forks source link

main thread hang at several GUI actions #49

Closed albertz closed 10 years ago

albertz commented 10 years ago

While resizing the window:

! Main Thread is hanging for more than 5.000000 secs
! Main Thread backtrace
backtrace() returned 31 addresses
0   MusicPlayer                         0x0000000100005ddd print_backtrace + 61
1   MusicPlayer                         0x000000010000709c _ZN5boost6detail8function26void_function_obj_invoker3IZN18ThreadHangDetector17_backgroundThreadEvEUliPvS4_E_viS4_S4_E6invokeERNS1_15function_bufferEiS4_S4_ + 44
2   MusicPlayer                         0x00000001000040a5 _ZL25_callstack_signal_handleriP9__siginfoPv + 69
3   libsystem_platform.dylib            0x00007fff8c1f35aa _sigtramp + 26
4   AppKit                              0x00007fff87bd1cf1 NSAppKitVersionNumber + 13489
5   CoreFoundation                      0x00007fff8f9cc315 __CFRunLoopServiceMachPort + 181
6   CoreFoundation                      0x00007fff8f9cb939 __CFRunLoopRun + 1161
7   CoreFoundation                      0x00007fff8f9cb275 CFRunLoopRunSpecific + 309
8   HIToolbox                           0x00007fff8cf54f0d RunCurrentEventLoopInMode + 226
9   HIToolbox                           0x00007fff8cf54cb7 ReceiveNextEventCommon + 479
10  HIToolbox                           0x00007fff8cf54abc _BlockUntilNextEventMatchingListInModeWithFilter + 65
11  AppKit                              0x00007fff871a428e _DPSNextEvent + 1434
12  AppKit                              0x00007fff871a38db -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
13  AppKit                              0x00007fff87aadfdd +[NSWindow(NSWindowResizing) _mouseHysteresisCheck:withExpiration:andDistance:finalMouseLocation:] + 405
14  AppKit                              0x00007fff873bd677 -[NSWindow(NSWindowResizing) _hitTestWithHysteresisCheck:forEvent:allowWindowDragging:] + 309
15  AppKit                              0x00007fff873a79ce -[NSWindow sendEvent:] + 6374
16  AppKit                              0x00007fff87347744 -[NSApplication sendEvent:] + 2021
17  AppKit                              0x00007fff87197a29 -[NSApplication run] + 646
18  _guiCocoa.so                        0x0000000107e56352 _Z13guiCocoa_mainP7_object + 178
19  Python.dylib                        0x000000010004e9ac PyEval_EvalFrameEx + 12106
20  Python.dylib                        0x000000010004b90c PyEval_EvalCodeEx + 1574
21  Python.dylib                        0x0000000100051e99 fast_function + 311
22  Python.dylib                        0x000000010004eafe PyEval_EvalFrameEx + 12444
23  Python.dylib                        0x000000010004b90c PyEval_EvalCodeEx + 1574
24  Python.dylib                        0x000000010004b2e0 PyEval_EvalCode + 54
25  Python.dylib                        0x000000010004994e run_mod + 53
26  Python.dylib                        0x00000001000499f5 PyRun_FileExFlags + 137
27  Python.dylib                        0x0000000100049543 PyRun_SimpleFileExFlags + 718
28  MusicPlayer                         0x0000000100005902 _Z12main_wrappediPPc + 1378
29  MusicPlayer                         0x0000000100003b0a main + 74
30  MusicPlayer                         0x0000000100003304 start + 52
All Python threads:
Thread 0x000000010d504000:
  File "utils.py", line 1094 in get
  File "itunes.py", line 242 in loadRatings
  File "utils.py", line 1359 in doCall
  File "threading.py", line 761 in run
  File "threading.py", line 808 in __bootstrap_inner
  File "threading.py", line 781 in __bootstrap

Thread 0x000000010d101000:
  File "guiCocoa.py", line 401 in playCursorUpdater
  File "utils.py", line 1359 in doCall
  File "threading.py", line 761 in run
  File "threading.py", line 808 in __bootstrap_inner
  File "threading.py", line 781 in __bootstrap

Current thread 0x00007fff75857310:
  File "main.py", line 159 in main
  File "main.py", line 196 in <module>
! No active Python thread

The backtrace is not totally fixed, it might also look a bit different (e.g. being in -[NSWindow(NSWindowResizing) _resizeWithEvent:] + 838).

We could maybe detect this by checking if there occurs NSWindowResizing in the backtrace and everything on top is not from MusicPlayer.


Another hang while holding mouse down on the window close button (the red dot):

! Main Thread is hanging for more than 5.000000 secs
! Main Thread backtrace
backtrace() returned 33 addresses
0   MusicPlayer                         0x0000000100005ddd print_backtrace + 61
1   MusicPlayer                         0x000000010000709c _ZN5boost6detail8function26void_function_obj_invoker3IZN18ThreadHangDetector17_backgroundThreadEvEUliPvS4_E_viS4_S4_E6invokeERNS1_15function_bufferEiS4_S4_ + 44
2   MusicPlayer                         0x00000001000040a5 _ZL25_callstack_signal_handleriP9__siginfoPv + 69
3   libsystem_platform.dylib            0x00007fff8c1f35aa _sigtramp + 26
4   ???                                 0x0000000000000000 0x0 + 0
5   CoreFoundation                      0x00007fff8f9cc315 __CFRunLoopServiceMachPort + 181
6   CoreFoundation                      0x00007fff8f9cb939 __CFRunLoopRun + 1161
7   CoreFoundation                      0x00007fff8f9cb275 CFRunLoopRunSpecific + 309
8   HIToolbox                           0x00007fff8cf54f0d RunCurrentEventLoopInMode + 226
9   HIToolbox                           0x00007fff8cf54cb7 ReceiveNextEventCommon + 479
10  HIToolbox                           0x00007fff8cf54abc _BlockUntilNextEventMatchingListInModeWithFilter + 65
11  AppKit                              0x00007fff871a428e _DPSNextEvent + 1434
12  AppKit                              0x00007fff871a38db -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
13  AppKit                              0x00007fff87428295 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 1164
14  AppKit                              0x00007fff87427ae7 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 487
15  AppKit                              0x00007fff874271fd -[NSControl mouseDown:] + 706
16  AppKit                              0x00007fff878bd5f1 -[_NSThemeWidget mouseDown:] + 304
17  AppKit                              0x00007fff873a8d08 -[NSWindow sendEvent:] + 11296
18  AppKit                              0x00007fff87347744 -[NSApplication sendEvent:] + 2021
19  AppKit                              0x00007fff87197a29 -[NSApplication run] + 646
20  _guiCocoa.so                        0x00000001087f0332 _Z13guiCocoa_mainP7_object + 178
21  Python.dylib                        0x000000010004e9ac PyEval_EvalFrameEx + 12106
22  Python.dylib                        0x000000010004b90c PyEval_EvalCodeEx + 1574
23  Python.dylib                        0x0000000100051e99 fast_function + 311
24  Python.dylib                        0x000000010004eafe PyEval_EvalFrameEx + 12444
25  Python.dylib                        0x000000010004b90c PyEval_EvalCodeEx + 1574
26  Python.dylib                        0x000000010004b2e0 PyEval_EvalCode + 54
27  Python.dylib                        0x000000010004994e run_mod + 53
28  Python.dylib                        0x00000001000499f5 PyRun_FileExFlags + 137
29  Python.dylib                        0x0000000100049543 PyRun_SimpleFileExFlags + 718
30  MusicPlayer                         0x0000000100005902 _Z12main_wrappediPPc + 1378
31  MusicPlayer                         0x0000000100003b0a main + 74
32  MusicPlayer                         0x0000000100003304 start + 52
All Python threads:
Thread 0x000000010ded2000:
  File "guiCocoa.py", line 401 in playCursorUpdater
  File "utils.py", line 1359 in doCall
  File "threading.py", line 761 in run
  File "threading.py", line 808 in __bootstrap_inner
  File "threading.py", line 781 in __bootstrap

Current thread 0x00007fff75857310:
  File "main.py", line 159 in main
  File "main.py", line 196 in <module>
! No active Python thread

do_in_mainthread still seems to work because the window can get updates in the meanwhile. So maybe we should use another life signal method.

albertz commented 10 years ago

Fixed in 9d6b18a9.