[apple_hevc] v0.0.2: fix file-test crash on failed probe + mimetypes thread race - #514
Merged
Merged
Conversation
Fix the library-management file test crashing whenever the file probe fails: Probe.init_probe() returns None on a failed probe and the plugin dereferenced it (AttributeError: 'NoneType' object has no attribute 'file'). Each crash aborts the whole file-test chain for that file. This mirrors the fix the plugin author committed to their development repo (k29t59dh/unmanic-plugins@0e41183) which was never released here. Also fix the underlying reason probes were failing at all: the vendored ffmpeg helper lib calls mimetypes.init() on every Probe() instantiation, rebuilding Python's global mimetype database. Under Unmanic's concurrent file-tester threads this races guess_type() in other threads into returning None for valid mp4 files, which silently skipped them during scans (observed: 168 crashes in one scan; ~160 hev1 mp4s never queued). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The vendored apple_hevc here is v0.0.1, whose library-management file test crashes whenever the file probe fails:
Probe.init_probe()returnsNoneon a failed probe and the plugin dereferences it (AttributeError: 'NoneType' object has no attribute 'file'). Each crash aborts the entire file-test chain for that file, so subsequent plugins never run on it either.The probes fail more than you'd expect, because of a thread race in the vendored ffmpeg helper lib:
Probe.__init__callsmimetypes.init()on every instantiation, rebuilding Python's global mimetype database — and Unmanic runs file tests on several concurrent tester threads, so other threads'guess_type()calls race the rebuild and getNonefor valid mp4 files. Observed on a live library: 168 crashes in a single scan; ~160 hev1 mp4s silently never queued for their hvc1 remux, clustered by directory (thread timing).Fix
init_proberesult before use — this mirrors the fix the plugin author committed to their development repo (k29t59dh/unmanic-plugins@0e41183, also proposed for release in [apple_hevc] v0.0.2: fix mimetypes thread race + release the unshipped crash fix k29t59dh/unmanic-plugins#1) which never shipped here. The worker-stage call site constructsProbedirectly and is unaffected.mimetypes.init()withmimetypes.initedin the vendored lib (same fix proposed for the shared helper repo in Fix thread race: only call mimetypes.init() once Josh5/unmanic.plugin.helpers.ffmpeg#7).Testing: verified against Unmanic
0.4.0+e838573(josh5/unmanic:latest), 4 concurrent file testers + 3 QSV workers: all previously-skipped hev1 mp4s queue correctly and remux to hvc1 (ffprobe-verified). No new python files introduced.🤖 Generated with Claude Code