-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
System and IINA version:
- macOS 12.1
- IINA 1.2.0 + changes
Expected behavior:
IINA quits without crashing.
Actual behavior:
While terminating IINA crashed in mpv_get_property_string
while NowPlayingInfoManager.updateInfo
was trying to obtain the media title.
The sequence that triggered the crash was:
- Started IINA from Xcode
- Entered PiP mode
- Minimized main window
- Selected quit from the menu
But that sequence may not be important. This is a thread race condition during termination.
This was with a version of IINA built from the develop branch with updated dependencies including mpv 0.34.1. The build did not include the changes in PR #3591 that increase the window of vulnerability during termination.
As might be expected debugging showed PlayerCore
had initiated mpv termination:
isMpvTerminated = true
And mpv had emitted the MPV_EVENT_SHUTDOWN
event and the mpv context was destroyed:
mpv = nil
Which explains why mpv_get_property_string
crashed.
Crashed Thread Stack Trace
Thread 1 Queue : com.apple.main-thread (serial)
#0 0x0000000105208a8c in mpv_get_property_string ()
#1 0x00000001024a6fdc in MPVController.getString(_:) at /Users/low-batt/Documents/builds/iina/iina/iina/MPVController.swift:500
#2 0x000000010247a9c8 in PlayerCore.getMediaTitle(withExtension:) at /Users/low-batt/Documents/builds/iina/iina/iina/PlayerCore.swift:1580
#3 0x000000010246d1d4 in static NowPlayingInfoManager.updateInfo(withTitle:) at /Users/low-batt/Documents/builds/iina/iina/iina/PlayerCore.swift:1744
#4 0x0000000102306a00 in PlayerWindowController.windowDidBecomeMain(_:) at /Users/low-batt/Documents/builds/iina/iina/iina/PlayerWindowController.swift:410
#5 0x0000000102288700 in MainWindowController.windowDidBecomeMain(_:) at /Users/low-batt/Documents/builds/iina/iina/iina/MainWindowController.swift:1447
#6 0x000000010228881c in @objc MainWindowController.windowDidBecomeMain(_:) ()
#7 0x0000000187945200 in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
#8 0x00000001879e8b84 in ___CFXRegistrationPost_block_invoke ()
#9 0x00000001879e8af0 in _CFXRegistrationPost ()
#10 0x0000000187913eb0 in _CFXNotificationPost ()
#11 0x00000001887c9e3c in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#12 0x000000018a5d9f9c in -[NSWindow _changeKeyAndMainLimitedOK:] ()
#13 0x000000018a5d9964 in -[NSWindow _makeKeyRegardlessOfVisibility] ()
#14 0x000000018a5cf5f0 in -[NSWindow makeKeyAndOrderFront:] ()
#15 0x000000018ad52a64 in -[NSWindow(NSWindow_Theme) _finishDeminiaturizeFromDock:] ()
#16 0x000000018a6192f0 in _NSCGSDockMessageReceive ()
#17 0x0000000190507ef0 in DockCallback(unsigned int, unsigned int, void*, void*) ()
#18 0x000000018d53e324 in _DCXTransactionComplete ()
#19 0x000000018d53e2c0 in _XTransactionComplete ()
#20 0x000000018d52f1ec in mshMIGPerform ()
#21 0x00000001879514d8 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#22 0x0000000187951394 in __CFRunLoopDoSource1 ()
#23 0x000000018794f820 in __CFRunLoopRun ()
#24 0x000000018794e734 in CFRunLoopRunSpecific ()
#25 0x000000018d53e240 in waitForTransaction ()
#26 0x000000018ad52c20 in -[NSWindow(NSWindow_Theme) _doRestoreComingFromDock:forceActivation:wantsToBeKey:] ()
#27 0x00000001022a517c in MainWindowController.prepareForPIPClosure(_:) at /Users/low-batt/Documents/builds/iina/iina/iina/MainWindowController.swift:2638
#28 0x00000001022a524c in MainWindowController.pipShouldClose(_:) at /Users/low-batt/Documents/builds/iina/iina/iina/MainWindowController.swift:2646
#29 0x00000001022a5294 in @objc MainWindowController.pipShouldClose(_:) ()
#30 0x00000001022810d8 in MainWindowController.exitPIP() at /Users/low-batt/Documents/builds/iina/iina/iina/MainWindowController.swift:2583
#31 0x00000001022804b4 in MainWindowController.windowWillClose(_:) at /Users/low-batt/Documents/builds/iina/iina/iina/MainWindowController.swift:1043
#32 0x00000001022813f0 in @objc MainWindowController.windowWillClose(_:) ()
#33 0x0000000187945200 in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
#34 0x00000001879e8b84 in ___CFXRegistrationPost_block_invoke ()
#35 0x00000001879e8af0 in _CFXRegistrationPost ()
#36 0x0000000187913eb0 in _CFXNotificationPost ()
#37 0x00000001887c9e3c in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#38 0x000000018ad47d2c in -[NSWindow _finishClosingWindow] ()
#39 0x000000018a7bdb34 in -[NSWindow _close] ()
#40 0x000000018a80dbbc in -[NSWindow _closeForTermination] ()
#41 0x000000018797debc in -[NSArray makeObjectsPerformSelector:] ()
#42 0x000000018a73b5fc in -[NSApplication _deallocHardCore:] ()
#43 0x000000018a72aad4 in -[NSApplication terminate:] ()
#44 0x000000018a88a1c8 in -[NSApplication _terminateFromSender:askIfShouldTerminate:saveWindows:] ()
#45 0x000000018a88a098 in __52-[NSApplication(NSAppleEventHandling) _handleAEQuit]_block_invoke ()
#46 0x000000018a8dbf10 in ___NSMainRunLoopPerformBlockInModes_block_invoke ()
#47 0x0000000187950708 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ ()
#48 0x000000018795057c in __CFRunLoopDoBlocks ()
#49 0x000000018794f1f4 in __CFRunLoopRun ()
#50 0x000000018794e734 in CFRunLoopRunSpecific ()
#51 0x00000001904e0f68 in RunCurrentEventLoopInMode ()
#52 0x00000001904e0bf4 in ReceiveNextEventCommon ()
#53 0x00000001904e0a9c in _BlockUntilNextEventMatchingListInModeWithFilter ()
#54 0x000000018a4a4ce0 in _DPSNextEvent ()
#55 0x000000018a4a3584 in -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] ()
#56 0x000000018a4955a4 in -[NSApplication run] ()
#57 0x000000018a466c78 in NSApplicationMain ()
#58 0x00000001022fadfc in main at /Users/low-batt/Documents/builds/iina/iina/iina/AppDelegate.swift:22
#59 0x0000000102e510f4 in start ()
Steps to reproduce:
This is an event / thread race condition, so very difficult to reproduce.
I will post a proposed fix shortly.
- MPV does not have this problem.
This is an IINA problem.
How often does this happen?
Rarely.