Marginal / QLVideo

This package allows macOS Finder to display thumbnails, static QuickLook previews, cover art and metadata for most types of video files.
GNU General Public License v2.0
2.51k stars 87 forks source link

QLVideo crashes on preview of any .mkv file #103

Closed Cueball closed 1 year ago

Cueball commented 1 year ago

Any time I'm in the Finder where there are mkv files, I can expect quicklook to die multiple times.

It's only mkv files that I've had problems with; mp4 files of any sort work fine.

Crash report prefix info is:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               ExternalQuickLookSatellite-x86_64 [35656]
Path:                  /System/Library/Frameworks/QuickLook.framework/Versions/A/XPCServices/ExternalQuickLookSatellite-x86_64.xpc/Contents/MacOS/ExternalQuickLookSatellite-x86_64
Identifier:            com.apple.quicklook.externalSatellite.x86_64
Version:               5.0 (521.1)
Build Info:            QuickLook_satellite-950002000000000~490
Code Type:             X86-64 (Native)
Parent Process:        launchd [1]
Responsible:           quicklookd [35655]
User ID:               502

Date/Time:             2022-12-01 21:18:14.3688 +0800
OS Version:            macOS 12.5.1 (21G83)
Report Version:        12
Anonymous UUID:        80B1EE5E-8CEE-D257-DB33-C53BC77848AB

Time Awake Since Boot: 1100000 seconds

System Integrity Protection: enabled

Crashed Thread:        1  Dispatch queue: quicklookd.serialgenerator

Exception Type:        EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes:       0x0000000000000001, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace SIGNAL, Code 4 Illegal instruction: 4
Terminating Process:   exc handler [35656]

[Can post a full backtrace if needed; this isn't hard to replicate. Edit: confirming that the backtrace firmly points at QLVideo, but the references ares scattered throughout a lot of text.]

Poking around the Video binary and using lipo to strip the arm64 content yields a different error that's almost identical to this issue: #96 comment

Between stripping the arm64 content and the EXC_BAD_INSTRUCTION (SIGILL) I suspect the arm64 code might be being called accidentally on x86_64? [I don't know how that's possible, but SIGILL does usually mean an invalid CPU instruction - but not always, so...]

I think this was introduced in 1.96, but I can't be entirely sure [I'd roll back to the earlier version I had installed but #timemachineproblems; sorry.] Lemme know if you need more info or to try stuff out and I'll try to get that too.

Cueball commented 1 year ago

[Less reliably reproducible, but happened just now...]

QLVideo also causing mdworker to crash when trying to index .mkv files. Initial crash report:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               mdworker [80430]
Path:                  /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Support/mdworker
Identifier:            mdworker
Version:               ???
Code Type:             X86-64 (Native)
Parent Process:        launchd [1]
User ID:               502

Date/Time:             2022-12-03 01:03:25.4810 +0800
OS Version:            macOS 12.5.1 (21G83)
Report Version:        12
Anonymous UUID:        80B1EE5E-8CEE-D257-DB33-C53BC77848AB

Time Awake Since Boot: 1200000 seconds

System Integrity Protection: enabled

Crashed Thread:        2

Exception Type:        EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes:       0x0000000000000001, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace SIGNAL, Code 4 Illegal instruction: 4
Terminating Process:   exc handler [80430]

Application Specific Signatures:
import uti:org.matroska.mkv plugin:/Library/Spotlight/Video.mdimporter uuid:3BD30E87-1D12-4322-AFCE-F58CB4B56096 1.9.6

Thread 0::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib              0x7ff80e75497a mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff80e754ce8 mach_msg + 56
2   CoreFoundation                      0x7ff80e857560 __CFRunLoopServiceMachPort + 319
3   CoreFoundation                      0x7ff80e855bf0 __CFRunLoopRun + 1276
4   CoreFoundation                      0x7ff80e855034 CFRunLoopRunSpecific + 562
5   CoreFoundation                      0x7ff80e8dc567 CFRunLoopRun + 40
6   mdworker                               0x108844cc0 0x10883a000 + 44224
7   dyld                                   0x110b6d52e start + 462

Thread 1:
0   libsystem_pthread.dylib             0x7ff80e78cf48 start_wqthread + 0

Thread 2 Crashed:
0   Video                                  0x10da8a634 aa_probe + 4
1   Video                                  0x10daca758 av_probe_input_format3 + 744
2   ???                                 0x70000c72c098 ???

Thread 2 crashed with X86 Thread State (64-bit):
  rax: 0x00007fc894809200  rbx: 0x000000010eb78818  rcx: 0x0000000000000001  rdx: 0x0000000000000049
  rdi: 0x000070000c72c010  rsi: 0x000000010e79ced1  rbp: 0x000070000c72c030  rsp: 0x000070000c72bff8
   r8: 0x000000000000006d   r9: 0x00000000000008f0  r10: 0x000000010daa3a10  r11: 0xffffffffffff8000
  r12: 0x0000000000000000  r13: 0x000070000c72c098  r14: 0x0000000000000000  r15: 0x0000000000000000
  rip: 0x000000010da8a634  rfl: 0x0000000000010206  cr2: 0x0000000141f5fef0

Logical CPU:     0
Error Code:      0x00000000 
Trap Number:     6

Thread 2 instruction stream:
  00 89 c5 09 dd 89 e8 f7-d0 a9 f0 ff 00 00 75 bc  ..............u.
  49 8b 7f 20 48 c7 c6 fe-ff ff ff ba 01 00 00 00  I.. H...........
  e8 87 ab 01 00 49 8b 47-20 31 c9 66 83 fd f0 ba  .....I.G 1.f....
  b7 b1 bb be 0f 43 d1 83-78 50 00 b8 bb b0 b9 df  .....C..xP......
  0f 44 c2 48 83 c4 08 5b-41 5e 41 5f 5d c3 90 90  .D.H...[A^A_]...
  90 90 90 90 90 90 90 90-90 90 90 90 48 8b 47 08  ............H.G.
 [0f]38 f0 40 04 31 c9 3d-36 75 90 57 b8 32 00 00  .8.@.1.=6u.W.2.. <==
  00 0f 45 c1 c3 0f 1f 80-00 00 00 00 55 48 89 e5  ..E.........UH..
  41 57 41 56 41 55 41 54-53 48 83 e4 e0 48 81 ec  AWAVAUATSH...H..
  40 02 00 00 48 8b 05 a1-c9 0e 01 48 8b 00 48 89  @...H......H..H.
  84 24 20 02 00 00 c5 f8-57 c0 c5 fc 29 84 24 00  .$ .....W...).$.
  02 00 00 49 89 ff c5 fc-29 84 24 e0 01 00 00 c5  ...I....).$.....

Binary Images:
    0x7ff80e753000 -     0x7ff80e78afff libsystem_kernel.dylib (*) <792406fe-2224-3c14-ba9f-f076fd7839d2> /usr/lib/system/libsystem_kernel.dylib
    0x7ff80e7d8000 -     0x7ff80ecd8fff com.apple.CoreFoundation (6.9) <32d2d187-4e52-376e-bc07-245a48c37e2b> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
       0x10883a000 -        0x108895fff mdworker (*) <fd49d6fe-55b6-3958-82f4-2c84eba288d3> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Support/mdworker
       0x110b68000 -        0x110bd3fff dyld (*) <f71fb3ca-5fcc-3577-9457-b047888a46d1> /usr/lib/dyld
    0x7ff80e78b000 -     0x7ff80e796fff libsystem_pthread.dylib (*) <f32b6d06-b156-3da0-b086-a31cf011362b> /usr/lib/system/libsystem_pthread.dylib
       0x10da83000 -        0x10eb76fff com.apple.uk.org.marginal.qlvideo.mdimporter (1.96) <f32bf698-970c-39f9-8598-cea7560c7771> /Library/Spotlight/Video.mdimporter/Contents/MacOS/Video
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???

The ExternalQuickLookSatellite-x86_64 process will crash at around the same time as the mdworker process: the latter won't always crash on .mkv files, but the former (as in the initial report) will always crash.

Marginal commented 1 year ago

I don't think this is related to #96. More likely the fact that QLVideo now assumes the CPU supports AVX2 instructions. What model of Mac are you on, and are you running under virtualisation (VirtualBox, UTM, etc)?

Also, what does sysctl -a | grep avx return?

Cueball commented 1 year ago

I'm not running it on a machine that supports AVX2 (not a VM), but IMHO QLVideo shouldn't assume this.

macOS Monterey doesn't even assume AVX2, as it's supported on trashcan MPs (2013). Those CPUs are Ivy Bridge - so no AVX2. And Monterey has been working pretty well for me up until I got the 1.96 update of QLVideo via Homebrew.

AVX2 as a requirement isn't mentioned in the 1.96 release notes - introducing CPU requirements beyond what the OS requires is obviously your call [some other apps like VMware Fusion are notorious for doing that], but it'd be nice to get a heads up on that.

May I suggest that QLVideo should check for whether AVX2 instructions are present, and use them in that case - rather than just assuming they're present?

Marginal commented 1 year ago

I'm surprised and impressed that you can run Monterey - my late-2013 iMac struggles with Big Sur so I haven't tried to update it further.

Allowing FFmpeg to assume AVX2 shows some noticeable performance improvement and IMO it isn't unreasonable to not support ≥ 9 year old hardware. The limitation is mentioned here. I'll make this clearer and also show an alert in the next version to avoid wasting people's time.

If you have Xcode you can change this line and rebuild the project to restore support for IvyBridge.

Cueball commented 1 year ago

Thanks for the tip on building ffmpeg [I did look throught the top-level Xcode project (the raw xml, not in Xcode) for some sort of relevant build flag, but obviously that wasn't the right place]. Will give it a go when I'm done with AoC code puzzles lol.

You might find Monterey performs better than Big Sur on that iMac. I guess it doesn't matter now, but I'm actually on a patched 2012 Mac Mini w i5...works great, or at least good enough for the time being [can't afford anything new right now.]

Also, that trashcan MP was sold until mid 2017 or late 2019 for the maxed-out models, so not really ≥ 9yo hardware - but depends on your perspective I suppose.

Anyway, thanks for your efforts and for the reply; much appreciated. 👍

MikeRich88 commented 1 year ago

AVX2

:( this no longer runs on my 2010 Mac Pro then.

Intel(R) Xeon(R) CPU W3690 @ 3.47GHz

Marginal commented 1 year ago

I've made Release 1.99 with support for older hardware

MikeRich88 commented 1 year ago

It is very much appreciated, thanks. The .avi's, etc. not working was really the only issue so this should be a fine release.

It's really a shame Apple had to squander QuickTime 7 though. I used an old iMac 2009 a few weeks ago that booted Leopard and had Perian and Flip4Mac installed. The whole thing was like magic, QuickLook full motion previews, WMV's would open in any app. That was because anyone could add codecs to QuickTime 7.