media-kit / media-kit

A cross-platform video player & audio player for Flutter & Dart.
https://github.com/media-kit/media-kit
MIT License
1.09k stars 177 forks source link

[Crash][macOS] Abort Signal on macOS #830

Closed bdlukaa closed 1 week ago

bdlukaa commented 4 months ago

A few customers have reported crashes on macOS.

Logs ``` Translated Report (Full Report Below) ------------------------------------- Process: unity [27047] Path: /Applications/bluecherry.app/Contents/MacOS/unity Identifier: com.unity Version: 3.0.016 (3.0.016) Code Type: ARM-64 (Native) Parent Process: launchd [1] User ID: 501 Date/Time: 2024-05-13 16:01:32.4406 -0400 OS Version: macOS 14.1 (23B2073) Report Version: 12 Anonymous UUID: A8E268FC-06FA-A634-87AB-62300C0AB2AC Sleep/Wake UUID: 20E0237C-8B7A-41E4-93B8-C6DAB709E80B Time Awake Since Boot: 120000 seconds Time Since Wake: 401 seconds System Integrity Protection: enabled Crashed Thread: 44 */mpv core Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: Namespace SIGNAL, Code 6 Abort trap: 6 Terminating Process: unity [27047] Thread 0:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x1863108b4 mach_msg2_trap + 8 1 libsystem_kernel.dylib 0x186322d30 mach_msg2_internal + 80 2 libsystem_kernel.dylib 0x1863194f0 mach_msg_overwrite + 476 3 libsystem_kernel.dylib 0x186310c38 mach_msg + 24 4 CoreFoundation 0x18642dea4 __CFRunLoopServiceMachPort + 160 5 CoreFoundation 0x18642c76c __CFRunLoopRun + 1208 6 CoreFoundation 0x18642bc5c CFRunLoopRunSpecific + 608 7 HIToolbox 0x1909a7448 RunCurrentEventLoopInMode + 292 8 HIToolbox 0x1909a7284 ReceiveNextEventCommon + 648 9 HIToolbox 0x1909a6fdc _BlockUntilNextEventMatchingListInModeWithFilter + 76 10 AppKit 0x189c06be0 _DPSNextEvent + 660 11 AppKit 0x18a3dce8c -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716 12 AppKit 0x189bfa08c -[NSApplication run] + 476 13 AppKit 0x189bd1358 NSApplicationMain + 880 14 unity 0x1040e7474 main + 12 15 dyld 0x185fd50e0 start + 2360 Thread 1: 0 libsystem_pthread.dylib 0x18634be28 start_wqthread + 0 Thread 2: 0 libsystem_pthread.dylib 0x18634be28 start_wqthread + 0 Thread 3: 0 libsystem_pthread.dylib 0x18634be28 start_wqthread + 0 Thread 4: 0 libsystem_pthread.dylib 0x18634be28 start_wqthread + 0 Thread 5:: io.flutter.ui 0 libsystem_malloc.dylib 0x1861805e8 _szone_free + 240 1 FlutterMacOS 0x108a54660 0x10847c000 + 6129248 2 FlutterMacOS 0x108a53adc 0x10847c000 + 6126300 3 FlutterMacOS 0x108c69348 0x10847c000 + 8311624 4 App 0x119bed878 kDartVmSnapshotInstructions + 21752 5 App 0x119cc6ac0 kDartIsolateSnapshotInstructions + 869376 6 App 0x119cc6a20 kDartIsolateSnapshotInstructions + 869216 7 App 0x119d5fccc kDartIsolateSnapshotInstructions + 1496588 8 App 0x11a02b184 kDartIsolateSnapshotInstructions + 4426436 9 App 0x11a02a700 kDartIsolateSnapshotInstructions + 4423744 10 App 0x119d8fc78 kDartIsolateSnapshotInstructions + 1693112 11 App 0x119d8f798 kDartIsolateSnapshotInstructions + 1691864 12 App 0x119d99084 kDartIsolateSnapshotInstructions + 1731012 13 App 0x119d92000 kDartIsolateSnapshotInstructions + 1702208 14 App 0x119d8df18 kDartIsolateSnapshotInstructions + 1685592 15 App 0x119d8f888 kDartIsolateSnapshotInstructions + 1692104 16 App 0x119d8fad8 kDartIsolateSnapshotInstructions + 1692696 17 App 0x119d8fad8 kDartIsolateSnapshotInstructions + 1692696 18 App 0x119d99084 kDartIsolateSnapshotInstructions + 1731012 19 App 0x119d92000 kDartIsolateSnapshotInstructions + 1702208 20 App 0x119d99084 kDartIsolateSnapshotInstructions + 1731012 21 App 0x119d992ec kDartIsolateSnapshotInstructions + 1731628 22 App 0x119d92148 kDartIsolateSnapshotInstructions + 1702536 23 App 0x119d99084 kDartIsolateSnapshotInstructions + 1731012 24 App 0x119d92000 kDartIsolateSnapshotInstructions + 1702208 25 App 0x119d8fad8 kDartIsolateSnapshotInstructions + 1692696 26 App 0x119d8fad8 kDartIsolateSnapshotInstructions + 1692696 27 App 0x119d99084 kDartIsolateSnapshotInstructions + 1731012 28 App 0x119d992ec kDartIsolateSnapshotInstructions + 1731628 29 App 0x119d92148 kDartIsolateSnapshotInstructions + 1702536 30 App 0x119d99084 kDartIsolateSnapshotInstructions + 1731012 31 App 0x119d92000 kDartIsolateSnapshotInstructions + 1702208 32 App 0x119d8fad8 kDartIsolateSnapshotInstructions + 1692696 33 App 0x119d99084 kDartIsolateSnapshotInstructions + 1731012 34 App 0x119d992ec kDartIsolateSnapshotInstructions + 1731628 35 App 0x119d92148 kDartIsolateSnapshotInstructions + 1702536 36 App 0x119d8fad8 kDartIsolateSnapshotInstructions + 1692696 37 App 0x119d8df18 kDartIsolateSnapshotInstructions + 1685592 38 App 0x119d8f888 kDartIsolateSnapshotInstructions + 1692104 39 App 0x119d99084 kDartIsolateSnapshotInstructions + 1731012 40 App 0x119d91f58 kDartIsolateSnapshotInstructions + 1702040 41 App 0x119d99084 kDartIsolateSnapshotInstructions + 1731012 42 App 0x119d92000 kDartIsolateSnapshotInstructions + 1702208 43 App 0x119d8df18 kDartIsolateSnapshotInstructions + 1685592 44 App 0x119d8f888 kDartIsolateSnapshotInstructions + 1692104 45 App 0x119d90820 kDartIsolateSnapshotInstructions + 1696096 46 App 0x119d3f104 kDartIsolateSnapshotInstructions + 1362500 47 App 0x119d904c0 kDartIsolateSnapshotInstructions + 1695232 48 App 0x119d90414 kDartIsolateSnapshotInstructions + 1695060 49 App 0x119d27d14 kDartIsolateSnapshotInstructions + 1267284 50 App 0x119d27c34 kDartIsolateSnapshotInstructions + 1267060 51 App 0x119d27bc4 kDartIsolateSnapshotInstructions + 1266948 52 App 0x119d27ab0 kDartIsolateSnapshotInstructions + 1266672 53 App 0x119d277ec kDartIsolateSnapshotInstructions + 1265964 54 App 0x119e19cb4 kDartIsolateSnapshotInstructions + 2258420 55 App 0x119e19b78 kDartIsolateSnapshotInstructions + 2258104 56 App 0x119e19c18 kDartIsolateSnapshotInstructions + 2258264 57 App 0x119e0a614 kDartIsolateSnapshotInstructions + 2195284 58 App 0x119e0a0ac kDartIsolateSnapshotInstructions + 2193900 59 App 0x119e09a64 kDartIsolateSnapshotInstructions + 2192292 60 App 0x119e09a2c kDartIsolateSnapshotInstructions + 2192236 61 App 0x119c19d94 kDartIsolateSnapshotInstructions + 161492 62 App 0x119c19ca4 kDartIsolateSnapshotInstructions + 161252 63 App 0x119c19994 kDartIsolateSnapshotInstructions + 160468 64 App 0x119c19868 kDartIsolateSnapshotInstructions + 160168 65 App 0x119c0ada8 kDartIsolateSnapshotInstructions + 100072 66 App 0x119c0ae68 kDartIsolateSnapshotInstructions + 100264 67 App 0x11a100f80 kDartIsolateSnapshotInstructions + 5302464 68 App 0x11a104b88 kDartIsolateSnapshotInstructions + 5317832 69 App 0x119c115d4 kDartIsolateSnapshotInstructions + 126740 70 App 0x119c143c4 kDartIsolateSnapshotInstructions + 138500 71 App 0x119c14380 kDartIsolateSnapshotInstructions + 138432 72 App 0x119c143f4 kDartIsolateSnapshotInstructions + 138548 73 App 0x119befef4 kDartVmSnapshotInstructions + 31604 74 FlutterMacOS 0x108d38d30 0x10847c000 + 9162032 75 FlutterMacOS 0x108d39450 0x10847c000 + 9163856 76 FlutterMacOS 0x108eafbf0 0x10847c000 + 10697712 77 FlutterMacOS 0x108c2b6b4 0x10847c000 + 8058548 78 FlutterMacOS 0x108c6ed4c 0x10847c000 + 8334668 79 FlutterMacOS 0x108cbd930 0x10847c000 + 8657200 80 FlutterMacOS 0x108be5bcc 0x10847c000 + 7773132 81 FlutterMacOS 0x108be94bc 0x10847c000 + 7787708 82 FlutterMacOS 0x108c24308 0x10847c000 + 8028936 83 FlutterMacOS 0x1084ebecc 0x10847c000 + 458444 84 FlutterMacOS 0x1084f44e4 0x10847c000 + 492772 85 CoreFoundation 0x186449cd0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 32 86 CoreFoundation 0x186449978 __CFRunLoopDoTimer + 972 87 CoreFoundation 0x1864494b0 __CFRunLoopDoTimers + 356 88 CoreFoundation 0x18642c9f4 __CFRunLoopRun + 1856 89 CoreFoundation 0x18642bc5c CFRunLoopRunSpecific + 608 90 FlutterMacOS 0x1084f4780 0x10847c000 + 493440 91 FlutterMacOS 0x1084ebcc8 0x10847c000 + 457928 92 FlutterMacOS 0x1084f30f0 0x10847c000 + 487664 93 libsystem_pthread.dylib 0x186351034 _pthread_start + 136 94 libsystem_pthread.dylib 0x18634be3c thread_start + 8 Thread 6:: io.flutter.raster 0 libsystem_kernel.dylib 0x1863108b4 mach_msg2_trap + 8 1 libsystem_kernel.dylib 0x186322d30 mach_msg2_internal + 80 2 libsystem_kernel.dylib 0x1863194f0 mach_msg_overwrite + 476 3 libsystem_kernel.dylib 0x186310c38 mach_msg + 24 4 CoreFoundation 0x18642dea4 __CFRunLoopServiceMachPort + 160 5 CoreFoundation 0x18642c76c __CFRunLoopRun + 1208 6 CoreFoundation 0x18642bc5c CFRunLoopRunSpecific + 608 7 FlutterMacOS 0x1084f4780 0x10847c000 + 493440 8 FlutterMacOS 0x1084ebcc8 0x10847c000 + 457928 9 FlutterMacOS 0x1084f30f0 0x10847c000 + 487664 10 libsystem_pthread.dylib 0x186351034 _pthread_start + 136 11 libsystem_pthread.dylib 0x18634be3c thread_start + 8 Thread 7:: io.flutter.io 0 libsystem_kernel.dylib 0x1863108b4 mach_msg2_trap + 8 1 libsystem_kernel.dylib 0x186322d30 mach_msg2_internal + 80 2 libsystem_kernel.dylib 0x1863194f0 mach_msg_overwrite + 476 ```
Video https://github.com/media-kit/media-kit/assets/45696119/0ee187b9-3bdb-40a8-a67e-c5a6612c8252

As for the crash, it looks like it comes from an abort signal, but I couldn't find anything that may be calling it.

I have never experienced this in my development machine.

Related issues and threads:

The app

The app is the Bluecherry Client.

The videos are initialized at the app start. Could this be the root of the issue? On Linux and Android, I've experienced crashes when doing so on startup and fixed by starting videos with a certain delay.

The video is a RTSP stream.

abdelaziz-mahdy commented 4 months ago

did this fix your issue? https://github.com/bluecherrydvr/unity/commit/09bb2c723aef0018705813152a47129affa63627 i think the crash is due to mpv not being initiated yet

bdlukaa commented 4 months ago

did this fix your issue?

As I said, I can not reproduce this on my testing machine. It is happening only to some of our customers.

i think the crash is due to mpv not being initiated yet

I can add a 1 second delay after mpv is initialized on macOS

abdelaziz-mahdy commented 4 months ago

Let me know if that was enough to fix it, for I have a MacBook but no crashes happened to me.

I think the delay will be a good workaround, but a proper waiting for initialization will be the cleaner route

Will check if it can be implemented or not, no promises here

bdlukaa commented 4 months ago

I'm not sure if there is any waiting for initialization. MediaKit.ensureInitialized() isn't a Future that can be awaited.

abdelaziz-mahdy commented 4 months ago

Yes I checked that, but I still want to look into it , maybe it takes time or a listener can be attached and await on it

ShadrackOngera commented 4 months ago

I also get the crash, and the app closses completely. I am developing on ubuntu

Bonfra04 commented 2 months ago

Hi, any updates on this? I'm also having the same issue on a build of the flutter app using the github action runner. Building it locally works fine.

Logs on stdout/stederr:

2024-07-26 23:55:54.947 my_app[63399:5923509] VideoOutput: enableHardwareAcceleration: true
Assertion failed: (group_index >= 0), function m_config_cache_from_shadow, file m_config_core.c, line 554.
[1]    63399 abort      ./my_app
DefEnge commented 2 months ago

After further investigation with @Bonfra04 we found out that changing the Mpv.framework inside "APP.app/Contents/Frameworks" with one provided from an App.app builded from local machine instead of Github Action, fixed the abort error. Regardless it isn't a proper fix because the Github action still outputs a bad build of App.app that contains the abort error.

DefEnge commented 2 months ago

Me and @Bonfra04 found out that the issue causing the abort error was the way our action would zip the app, it seems that using the "zip" command instead of "7z" caused the issue. We noticed that the same behavior applied even to the example app of the media-kit when using the "zip" command the app crashes with the abort, meanwhile using the 7z the app works properly.