fluffy-critter / bandcrash

Bandcamp-style batch encoder and web player for independent musicians
MIT License
57 stars 0 forks source link

Frequent crashing on macOS #99

Closed fluffy-critter closed 1 year ago

fluffy-critter commented 1 year ago

Describe the bug

After opening a few albums in the app, encoding causes the app to crash.

Reproduction steps

Steps to reproduce the behavior:

  1. open several albums and encode them

Expected behavior

A clear and concise description of what you expected to happen.

Crashing shouldn't happen

Screenshots

If applicable, add screenshots to help explain your problem.

Platform

Additional context

Probably something really annoying with the Qt widget ownership model, possibly to do with how the progress dialog works. Hopefully the planned improvements to the process dialog will fix this stuff.

fluffy-critter commented 1 year ago

The stack trace indicates it's in a widget's destructor:

0   QtWidgets                              0x11424ec14 QWidget::~QWidget() + 620
1   QtWidgets                              0x11424f45c QWidget::~QWidget() + 12
2   QtCore                                 0x107aec190 QObjectPrivate::deleteChildren() + 152
3   QtWidgets                              0x11424ee3c QWidget::~QWidget() + 1172
4   QtWidgets                              0x11424f45c QWidget::~QWidget() + 12
5   QtCore                                 0x107aec190 QObjectPrivate::deleteChildren() + 152
6   QtWidgets                              0x11424ee3c QWidget::~QWidget() + 1172
7   QtWidgets.abi3.so                      0x1124a2e40 QScrollAreaWrapper::~QScrollAreaWrapper() + 64
8   QtCore                                 0x107aec190 QObjectPrivate::deleteChildren() + 152
9   QtWidgets                              0x11424ee3c QWidget::~QWidget() + 1172
10  QtWidgets.abi3.so                      0x1124d2580 QSplitterWrapper::~QSplitterWrapper() + 64
11  QtCore                                 0x107aec190 QObjectPrivate::deleteChildren() + 152
12  QtWidgets                              0x11424ee3c QWidget::~QWidget() + 1172
13  QtWidgets.abi3.so                      0x112349b5c QWidgetWrapper::~QWidgetWrapper() + 64
14  QtCore                                 0x107aec190 QObjectPrivate::deleteChildren() + 152
15  QtWidgets                              0x11424ee3c QWidget::~QWidget() + 1172
16  QtWidgets.abi3.so                      0x112513eb0 QMainWindowWrapper::~QMainWindowWrapper() + 64
17  libshiboken6.abi3.6.6.dylib            0x105cc6548 SbkDeallocWrapperCommon(_object*, bool) + 344
18  Python                                 0x1062e3e50 subtype_dealloc + 996
19  Python                                 0x1062ac9ec dictkeys_decref + 1200
20  Python                                 0x1062a82d8 dict_dealloc + 148
21  libshiboken6.abi3.6.6.dylib            0x105ccab0c Shiboken::Object::deallocData(SbkObject*, bool) + 256
22  libshiboken6.abi3.6.6.dylib            0x105cc64d0 SbkDeallocWrapperCommon(_object*, bool) + 224
23  Python                                 0x1062e3e50 subtype_dealloc + 996
24  libshiboken6.abi3.6.6.dylib            0x105cca364 Shiboken::Object::destroy(SbkObject*, void*) + 232
25  QtWidgets.abi3.so                      0x112349b54 QWidgetWrapper::~QWidgetWrapper() + 56
26  QtCore                                 0x107aec190 QObjectPrivate::deleteChildren() + 152
27  QtWidgets                              0x11424ee3c QWidget::~QWidget() + 1172
28  QtWidgets.abi3.so                      0x112349b5c QWidgetWrapper::~QWidgetWrapper() + 64
29  libshiboken6.abi3.6.6.dylib            0x105cc6548 SbkDeallocWrapperCommon(_object*, bool) + 344
30  Python                                 0x1062e3e50 subtype_dealloc + 996
31  Python                                 0x10641a578 gc_collect_main + 4044
32  Python                                 0x10641b5f0 _PyObject_GC_Link + 232
33  Python                                 0x10641b6c8 _PyObject_GC_New + 108
34  Python                                 0x10637c9cc _PyEval_EvalFrameDefault + 22436
35  Python                                 0x1063899ec _PyEval_Vector + 156
36  Python                                 0x10625d108 _PyObject_FastCallDictTstate + 208
37  Python                                 0x1062ea754 slot_tp_init + 180
38  Python                                 0x1062e10d8 type_call + 136
39  Python                                 0x10625cd78 _PyObject_MakeTpCall + 128
40  Python                                 0x10638406c _PyEval_EvalFrameDefault + 52804
41  Python                                 0x1063899ec _PyEval_Vector + 156
42  Python                                 0x106261158 method_vectorcall + 364
43  libpyside6.abi3.6.6.dylib              0x105d2bdf0 PySide::SignalManager::callPythonMetaMethod(QMetaMethod const&, void**, _object*, bool) + 536
44  libpyside6.abi3.6.6.dylib              0x105d2b9b8 PySide::SignalManager::SignalManagerPrivate::qtMethodMetacall(QObject*, int, void**) + 760
45  QtCore                                 0x107af4184 0x107a28000 + 835972
46  QtGui                                  0x1132783e8 QAction::activate(QAction::ActionEvent) + 368
47  QtCore                                 0x107aece68 QObject::event(QEvent*) + 612
48  QtWidgets                              0x114214980 QApplicationPrivate::notify_helper(QObject*, QEvent*) + 272
49  QtWidgets                              0x1142157d4 QApplication::notify(QObject*, QEvent*) + 504
50  QtCore                                 0x107aaa404 QCoreApplication::notifyInternal2(QObject*, QEvent*) + 292
51  QtCore                                 0x107aab68c QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + 1448
52  libqcocoa.dylib                        0x112e25e34 0x112e10000 + 89652
53  libqcocoa.dylib                        0x112e269ec 0x112e10000 + 92652
54  CoreFoundation                         0x18aa9fd28 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28

Unfortunately it's hard to tell which widget. It looks like maybe there's something bad happening due to Python GC stomping on Qt GC though.

fluffy-critter commented 1 year ago

ScrollAreaWrapper indicates it's probably in the TrackListEditor's right panel. There's possibly something wonky with how self.track_editor maintains a reference in the editor as well as being handed off to the ScrollArea, but it makes no sense why this should happen when encoding starts (or maybe it's during .apply()?) since that widget isn't being destroyed at any time.

fluffy-critter commented 1 year ago

oh wait no in the debug log for the app the crash is happening well after encoding has started:

Starting encode with configuration: Options(input_dir='/Volumes/home/Music/albums/novembeat 2017/bounces', output_dir='/Users/fluffy/Music/asdf/Sockpuppet - Novembeat 2017', preview_encoder_args=['-q:a', '5'], mp3_encoder_args=['-q:a', '0'], ogg_encoder_args=['-q:a', '5'], flac_encoder_args=[], butler_path='/Users/fluffy/bin/butler', butler_args=[], do_preview=True, do_mp3=True, do_ogg=True, do_flac=True, do_cleanup=True, do_zip=True, do_butler=True, butler_target='fluffy/novembeat-2017', butler_prefix='')
Building preview
Building mp3
Building ogg
Building flac
/Users/fluffy/Music/asdf/Sockpuppet - Novembeat 2017/preview/01 Tape Lead.mp3: Setting TYER to 2017
/Users/fluffy/Music/asdf/Sockpuppet - Novembeat 2017/preview/01 Tape Lead.mp3: Setting TALB to Novembeat 2017
/Users/fluffy/Music/asdf/Sockpuppet - Novembeat 2017/preview/01 Tape Lead.mp3: Setting TPE1 to Sockpuppet
/Users/fluffy/Music/asdf/Sockpuppet - Novembeat 2017/preview/01 Tape Lead.mp3: Setting TPE2 to Sockpuppet
/Users/fluffy/Music/asdf/Sockpuppet - Novembeat 2017/preview/01 Tape Lead.mp3: Setting TRCK to 1
/Users/fluffy/Music/asdf/Sockpuppet - Novembeat 2017/preview/01 Tape Lead.mp3: Setting TIT2 to Tape Lead
/Users/fluffy/Music/asdf/Sockpuppet - Novembeat 2017/preview/01 Tape Lead.mp3: Setting TCOM to j. shagam
/Users/fluffy/Music/asdf/Sockpuppet - Novembeat 2017/mp3/01 Tape Lead.mp3: Setting TYER to 2017
/Users/fluffy/Music/asdf/Sockpuppet - Novembeat 2017/mp3/01 Tape Lead.mp3: Setting TALB to Novembeat 2017
/Users/fluffy/Music/asdf/Sockpuppet - Novembeat 2017/mp3/01 Tape Lead.mp3: Setting TPE1 to Sockpuppet
/Users/fluffy/Music/asdf/Sockpuppet - Novembeat 2017/mp3/01 Tape Lead.mp3: Setting TPE2 to Sockpuppet
/Users/fluffy/Music/asdf/Sockpuppet - Novembeat 2017/mp3/01 Tape Lead.mp3: Setting TRCK to 1
/Users/fluffy/Music/asdf/Sockpuppet - Novembeat 2017/mp3/01 Tape Lead.mp3: Setting TIT2 to Tape Lead
/Users/fluffy/Music/asdf/Sockpuppet - Novembeat 2017/mp3/01 Tape Lead.mp3: Setting TCOM to j. shagam
Finished writing /Users/fluffy/Music/asdf/Sockpuppet - Novembeat 2017/ogg/01 Tape Lead.ogg
Finished writing /Users/fluffy/Music/asdf/Sockpuppet - Novembeat 2017/flac/01 Tape Lead.flac
zsh: segmentation fault  poetry run bandcrash-gui -vvv
fluffy-critter commented 1 year ago

calling gc.collectght help to narrow things down

fluffy-critter commented 1 year ago

Okay yeah as soon as gc.collect() runs on the second opened file, the crash happens. Even with the first one still being around. There's definitely something wrong with a widget reference somewhere.

fluffy-critter commented 1 year ago

Disabling the track editor causes the crash to stop happening, but bizarrely, it also makes it so that opening a new editor window causes the old one to close? Well that's interesting.