fix: python 3.14 compat issues on macOS#487
Open
vidonnus wants to merge 2 commits intojellyfin:masterfrom
Open
fix: python 3.14 compat issues on macOS#487vidonnus wants to merge 2 commits intojellyfin:masterfrom
vidonnus wants to merge 2 commits intojellyfin:masterfrom
Conversation
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.
Fix Python 3.14 Compatibility Issue on macOS
Issues
Closes #473
Closes #484
Problems
Issue 1: RuntimeError on startup (Python 3.14+)
On Python 3.14+, the application crashes on startup with:
This occurs in
mpv_shim.pywhen callingmultiprocessing.set_start_method()on macOS. In Python 3.14, the multiprocessing context is initialized earlier in the import process.Issue 2: Objective-C fork crash (Python 3.14 on macOS)
On Python 3.14 with macOS, the application crashes with:
This occurs because
forkserver(which still involves forking) is incompatible with macOS's Objective-C runtime when GUI frameworks are loaded.Root Cause
The original fix from 2020 set
forkserveron macOS to avoid crashes with theforkstart method. However:fork(unsafe with Objective-C) →forkserverwas a workaroundspawn(safe with Objective-C)RuntimeErrorif we try to set it againforkserversetting now causes crashes with Objective-C frameworksThe
forkservermethod still usesos.fork()internally, which is problematic on macOS when Objective-C frameworks (tkinter, pystray, PIL) have been initialized.Solution
RuntimeErrorwhen context is already set (Python 3.14+)spawninstead offorkserver: Safe for all Python versions on macOSforkdefault withspawnspawn(already the default, but ensures it)RuntimeErrorand Objective-C crashChanges
jellyfin_mpv_shim/mpv_shim.py
Impact
RuntimeErroron Python 3.14+ when context is already setTechnical Details
The
spawnmethod starts a fresh Python interpreter for each process, avoiding:This is why Python 3.8 changed the macOS default from
forktospawn.The try/except block ensures that if the context has already been set (Python 3.14+ behavior), we gracefully continue with the existing context rather than crashing.
Testing
Tested on: