leanflutter / tray_manager

This plugin allows Flutter desktop apps to defines system tray.
https://pub.dev/packages/tray_manager
MIT License
230 stars 36 forks source link

Mac app will crash when closing the tray. #44

Closed MegatronKing closed 3 months ago

MegatronKing commented 4 months ago

Call destroy() will crash the app, occurs by chance, not always.

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib                        0x1833a5408 objc_msgSend + 8
1   CoreFoundation                         0x1837f19f8 -[__NSDictionaryM objectForKey:] + 168
2   CoreFoundation                         0x183809a8c -[NSMutableDictionary __addObject:forKey:] + 96
3   CoreFoundation                         0x18380993c -[__NSFrozenDictionaryM __apply:context:] + 128
4   CoreFoundation                         0x183809000 -[CFPrefsSource mergeIntoDictionary:sourceDictionary:cloudKeyEvaluator:] + 168
5   CoreFoundation                         0x183802978 -[CFPrefsSearchListSource alreadylocked_getDictionary:] + 760
6   CoreFoundation                         0x1838023d8 -[CFPrefsSearchListSource alreadylocked_copyValueForKey:] + 172
7   CoreFoundation                         0x18380230c -[CFPrefsSource copyValueForKey:] + 52
8   CoreFoundation                         0x1838022c0 __76-[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:]_block_invoke + 32
9   CoreFoundation                         0x1837fb90c __108-[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke + 376
10  CoreFoundation                         0x18397e460 -[_CFXPreferences withSearchListForIdentifier:container:cloudConfigurationURL:perform:] + 384
11  CoreFoundation                         0x1837fb1e8 -[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:] + 156
12  CoreFoundation                         0x1837fb110 _CFPreferencesCopyAppValueWithContainerAndConfiguration + 112
13  Foundation                             0x184906568 -[NSUserDefaults(NSUserDefaults) objectForKey:] + 60
14  AppKit                                 0x186ff5f00 _NSGetBoolAppConfig + 84
15  AppKit                                 0x1872b39dc -[NSWindow close] + 368
16  AppKit                                 0x1877fc510 -[NSStatusItem _uninstall] + 76
17  tray_manager                           0x10157cc7c specialized TrayManagerPlugin.destroy(_:result:) + 164 (TrayManagerPlugin.swift:110)
18  tray_manager                           0x10157e81c specialized TrayManagerPlugin.destroy(_:result:) + 12 [inlined]
19  tray_manager                           0x10157e81c specialized TrayManagerPlugin.handle(_:result:) + 252 (<compiler-generated>:43)
20  tray_manager                           0x10157b630 specialized TrayManagerPlugin.handle(_:result:) + 16 [inlined]
21  tray_manager                           0x10157b630 @objc TrayManagerPlugin.handle(_:result:) + 84 (<compiler-generated>:40)
22  FlutterMacOS                           0x1044b9ab4 0x103af0000 + 10263220
23  FlutterMacOS                           0x103b01b80 0x103af0000 + 72576
24  FlutterMacOS                           0x104367634 0x103af0000 + 8877620
25  FlutterMacOS                           0x1043794e8 0x103af0000 + 8951016
26  FlutterMacOS                           0x104379ff8 0x103af0000 + 8953848
27  FlutterMacOS                           0x104376b3c 0x103af0000 + 8940348
28  FlutterMacOS                           0x10435fba0 0x103af0000 + 8846240
29  FlutterMacOS                           0x103b04a44 0x103af0000 + 84548
30  FlutterMacOS                           0x103b04bfc 0x103af0000 + 84988
31  libdispatch.dylib                      0x1835becb8 _dispatch_call_block_and_release + 32
32  libdispatch.dylib                      0x1835c0910 _dispatch_client_callout + 20
33  libdispatch.dylib                      0x1835cefa8 _dispatch_main_queue_drain + 984
34  libdispatch.dylib                      0x1835cebc0 _dispatch_main_queue_callback_4CF + 44
35  CoreFoundation                         0x183890ecc __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
36  CoreFoundation                         0x18384e7d0 __CFRunLoopRun + 1996
37  CoreFoundation                         0x18384d9ac CFRunLoopRunSpecific + 608
38  HIToolbox                              0x18ddfc448 RunCurrentEventLoopInMode + 292
39  HIToolbox                              0x18ddfc284 ReceiveNextEventCommon + 648
40  HIToolbox                              0x18ddfbfdc _BlockUntilNextEventMatchingListInModeWithFilter + 76
41  AppKit                                 0x18702a8a4 _DPSNextEvent + 660
42  AppKit                                 0x187804980 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716
43  AppKit                                 0x18701dd50 -[NSApplication run] + 476
44  AppKit                                 0x186ff5014 NSApplicationMain + 880
45  Reqable                                0x100d00f30 main + 12 (AppDelegate.swift:6)
46  dyld                                   0x1833f10e0 start + 2360

Full crash report was attached.

crash.log

lijy91 commented 3 months ago

Please upgrade to 0.2.3

NikitaPnch commented 1 month ago

Crash is still there:

First of all if we try use window_manager setPreventClose(true) and onWindowClose use windowManager.hide() thats destroy macos application

If we use hack fix from window_manager issue: https://github.com/leanflutter/window_manager/issues/431

apps will be hided but if we try to show window from tray, app will crash unexpectedly

crash tested on MacOS Sequoia beta 5 and MacOS Sonoma