status-im / status-desktop

Status Desktop client made in Nim & QML
https://status.app
Mozilla Public License 2.0
287 stars 78 forks source link

[Wallet][MacOS] App is crashing when the collectibles view is destroyed #13027

Closed alexjba closed 7 months ago

alexjba commented 9 months ago

This crash is currently hidden by using a StackLayout instead of a Loader to keep the collectibles view in memory (See https://github.com/status-im/status-desktop/pull/12953/commits/78800bdcdfef405277a703efd555a069dad3e166). The downside of the StackLayout is the memory consumption and there's also a chance for the app to crash on other flows even this change.

This task is to investigate the root cause of the crash.

The crashing flows point to the same call stack. The crash is always reported in the QQmlEngine while getting the QNAM. Seems to be related to the destruction of delegates, possible the animated images where we load the collectibles URLs:

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   QtQml                                    0x1059cb280 QQmlEngine::networkAccessManager() const + 16
1   QtQuick                                  0x104a62bc4 0x1048a8000 + 1813444
2   QtQuick                                  0x104a6283c 0x1048a8000 + 1812540
3   QtQuick                                  0x104a62d74 0x1048a8000 + 1813876
4   QtCore                                   0x106a74b24 0x106878000 + 2083620
5   QtNetwork                                0x104eb4c6c 0x104e4c000 + 429164
6   QtCore                                   0x106a6dbb0 QObject::event(QEvent*) + 596
7   QtCore                                   0x106a467b8 QCoreApplicationPrivate::notify_helper(QObject*, QEvent*) + 124
8   QtCore                                   0x106a46410 QCoreApplication::notifyInternal2(QObject*, QEvent*) + 292
9   QtCore                                   0x106a47524 QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + 464
10  libqcocoa.dylib                          0x13593dbd8 0x135900000 + 252888
11  libqcocoa.dylib                          0x13593e490 0x135900000 + 255120
12  CoreFoundation                           0x189f91cfc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
13  CoreFoundation                           0x189f91c90 __CFRunLoopDoSource0 + 176
14  CoreFoundation                           0x189f91a00 __CFRunLoopDoSources0 + 244
15  CoreFoundation                           0x189f905f0 __CFRunLoopRun + 828
16  CoreFoundation                           0x189f8fc5c CFRunLoopRunSpecific + 608
17  HIToolbox                                0x194509448 RunCurrentEventLoopInMode + 292
18  HIToolbox                                0x1945090d8 ReceiveNextEventCommon + 220
19  HIToolbox                                0x194508fdc _BlockUntilNextEventMatchingListInModeWithFilter + 76
20  AppKit                                   0x18d76ac54 _DPSNextEvent + 660
21  AppKit                                   0x18df40ebc -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716
22  AppKit                                   0x18d75e100 -[NSApplication run] + 476
23  libqcocoa.dylib                          0x13593d25c 0x135900000 + 250460
24  QtCore                                   0x106a429a4 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 544
25  QtCore                                   0x106a46a24 QCoreApplication::exec() + 132
26  nim_status_client                        0x102bb5690 0x102a24000 + 1644176
27  nim_status_client                        0x10378d474 0x102a24000 + 14062708
28  nim_status_client                        0x103842224 0x102a24000 + 14803492
29  nim_status_client                        0x103842390 main + 68
30  dyld                                     0x189b390e0 start + 2360

https://github.com/status-im/status-desktop/assets/97019400/719ee06f-6d95-4147-9b87-ce4280538797

https://github.com/status-im/status-desktop/assets/97019400/49af5b10-9f38-4e1f-aa53-e72bc6738240

Originally posted by @noeliaSD in https://github.com/status-im/status-desktop/pull/12953#pullrequestreview-1780499366

alexjba commented 9 months ago

If we're dealing with a Qt bug, there's also the possibility to update the Qt version to the latest 5.15 available.

alexjba commented 8 months ago

In this task the StackLayout should be replaced with a lazy loading mechanism.

alexjba commented 7 months ago

Cannot reproduce anymore. Probably fixed by the double grid view implementation. Probably fixed by https://github.com/status-im/status-desktop/issues/13045