Fix wxPython 4.2 / wxWidgets 3.2 compatibility (resolves macOS 14+ crash)#127
Open
jdlondon wants to merge 5 commits into
Open
Fix wxPython 4.2 / wxWidgets 3.2 compatibility (resolves macOS 14+ crash)#127jdlondon wants to merge 5 commits into
jdlondon wants to merge 5 commits into
Conversation
wxPython 4.2 is strict about integer coordinates for DC / GraphicsContext methods. A number of call sites still produced floats via Python 3 true division or arithmetic on float-valued attributes, and would crash with TypeError on modern wxPython. Wrap the offending values in int() at the call site, matching the pattern used in earlier fixes (commits 14a27ef and 8e97a59).
The underscored alias was removed in wxPython 4.2. The dotted form has been available for many versions and is backwards-compatible.
pyo is imported conditionally in audio.py (pyo64 vs pyo based on sample precision), so py2app's static analyser does not pick it up and omits it from the bundled app.
Python 2.7 is end-of-life; the bundled Python framework that py2app deploys is 3.11, and PyRuntimeLocations / PythonExecutable keys need to match, otherwise the app fails to locate the interpreter.
- Bump Python from 3.7 to 3.11 (3.7 is EOL). - Bump bundled wxWidgets dylibs from 3.1.4.0.0 to 3.2.0.4.2; the 3.1.4 CGShading callback crashes on macOS 14 Sonoma and later. - Fix broken find invocations (missing semicolons on -exec) and tighten the hidden-file cleanup to only remove .DS_Store (previous .* glob would also have removed __pycache__, .gitignore, etc.). - Flatten py2app's Resources/Resources/ nesting post-build so that constants.py's os.getcwd()-based RESOURCES_PATH resolves correctly.
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 Cecilia5 5.4.1 download on the project page crashes immediately
after the splash screen on macOS 14 (Sonoma) and later with a segfault
inside
libwx_osx_cocoau_core-3.1.4.0.0.dylibduringCGFunctionEvaluate. A native crash report shows the offending call isin the CGShading callback
(
wxMacCoreGraphicsPenBrushDataBase::CalculateShadingValues), whichreceives a NULL
infopointer on Sonoma's deferred display-listrenderer. The crash triggers on any gradient brush, and the Cecilia UI
uses gradients heavily (sliders, knobs, toggles, label triangles), so
it has no way to proceed. wxWidgets 3.2 handles the lifecycle
correctly.
Rebuilding against wxPython 4.2 / wxWidgets 3.2 avoids the crash but
exposes wxPython 4.2's stricter type checking for drawing-method
arguments (floats no longer silently coerced to int). Most such sites
were fixed on master by the 2021–2023 commits (
655954e,266d613,14a27ef,8e97a59), but a handful remain. Additionally,wx.GraphicsContext_Create(underscored alias) was removed inwxPython 4.2 and needs the dotted form.
Fixes (5 commits, each self-contained)
Fix remaining float values in wxPython 4.2 drawing calls.
13 call sites across
CeciliaPlot.py,Sliders.py,Widgets.py,Control.pywhere Python 3 true division or arithmetic on floatattributes produced floats. Fixed in place with
int(...)wrappersor
//division, matching the style established in commits14a27efand8e97a59. Includes thewx.Colour(knobcolor[0] * 0.25, ...)case atSliders.py:1484,which parallels the
* 0.35fix already applied to the siblingRangeSlider.setFillColouron master.Replace
wx.GraphicsContext_Createwithwx.GraphicsContext.Create.26 occurrences across 5 files. The underscored alias was removed in
wxPython 4.2; the dotted form has been available for many versions
and is backwards-compatible.
py2app: include
pyoexplicitly.pyois importedconditionally in
audio.py(pyo64 vs pyo based on sample precision),so py2app's static analyser misses it and omits it from the bundle.
info.plist: target Python 3.11. Updates
PyRuntimeLocations,PythonExecutable, and version strings from Python 2.7 stubs to3.11.
builder_OSX.sh: target Python 3.11 / wxWidgets 3.2. Bumps
install_name_toolpaths from3.1.4.0.0→3.2.0.4.2dylibs andpython3.7→python3.11. Also fixes brokenfind -execsyntax(missing semicolons on the
.git/.pyccleanup lines) and narrowsthe hidden-file cleanup to only
.DS_Storeso it doesn't alsostrip
.gitignore,__pycache__, etc. Adds a post-build step thatflattens py2app's
Contents/Resources/Resources/nesting, becauseconstants.pyexpectsRESOURCES_PATH == Contents/Resources.Testing
Built against Python 3.11.12 / wxPython 4.2.5 / wxWidgets 3.2.9 on
macOS 14.8.3. Verified with the bundled .app:
NoneType.sliderdownstream from awx.Colour(float)inbuildGrapher): loads cleanly.Sliders.py:1484fix): loads cleanly.
Pitch / Resonators&Verbs / Spectral / Synthesis / Time): all load
cleanly.
Note on the binary release
I notice that the 5.4.1 version on the project site predates the more
recent drawing fixes, and the official macOS binary has the wx crash
on Sonoma and later. Hopefully the fixes in this PR are helpful if
you're considering a future updated release. I've left the version in
the builder script at 5.4.1 for now.
AI usage disclosure: some parts of this PR and its summary were
prepared and validated using Opus 4.6 and 4.7.