Skip to content

Fix two macOS plugin-window bugs: nil-window max dimensions, unrecorded dpi scale - #97

Open
Crandall1 wants to merge 2 commits into
VitalAudio:mainfrom
Audio-Damage-Inc:mac-plugin-window-fixes
Open

Fix two macOS plugin-window bugs: nil-window max dimensions, unrecorded dpi scale#97
Crandall1 wants to merge 2 commits into
VitalAudio:mainfrom
Audio-Damage-Inc:mac-plugin-window-fixes

Conversation

@Crandall1

Copy link
Copy Markdown

Two small fixes for visage embedded as a plugin editor on macOS, found shipping a CLAP/AUv2 instrument. Both stem from the same situation: plugin views exist before the host puts them in an NSWindow, which is the normal AUv2/VST3 flow.

1. WindowMac::maxWindowDimensions messages a nil window

Every AUv2 host instantiates the plugin view before attaching it, so [window_handle_ screen] is nil and the visible frame comes back 0x0. adjustWindowDimensions then clamps every size query to nothing — with clap-helpers' strict checking, the resulting set_size/adjust_size disagreement terminates the process. Fall back to [NSScreen mainScreen] when unattached.

2. The parented WindowMac constructor never records its dpi scale

The standalone constructor calls setDpiScale(scale); the parented one drops it. Everything reading dpiScale() before the first backing-properties reset — including ApplicationEditor::addToWindow pushing dpi into the frame tree — sees 1.0, so on retina the tree lays out at half scale and mouse events land at double coordinates in every plugin host. The standalone path is unaffected, which hides the bug during development.

Verified in Ableton Live 12 and Logic Pro (AUv2, retina) and against the standalone.

🤖 Generated with Claude Code

AUv2 hosts create the plugin view before adding it to a window, so
maxWindowDimensions ran with a nil window handle: messaging nil gave a
0x0 visible frame, adjustWindowDimensions clamped every size to 0x0, and
clap-helpers' set_size/adjust_size cross-check terminated the process.
The host then fell back to its generic editor.

(cherry picked from commit 474bdaf)
The standalone constructor calls setDpiScale(scale); the parented one
never did. Everything reading dpiScale() before the first
backing-properties reset -- including ApplicationEditor::addToWindow
pushing dpi into the frame tree -- saw 1.0, so on retina displays every
plugin host laid the tree out at half scale and mouse events landed at
double coordinates. The standalone was unaffected, which is why the bug
only showed embedded.

(cherry picked from commit 0cdc3c7)
@Crandall1

Copy link
Copy Markdown
Author

I didn't see #93 until just now, but it is the same as my No. 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant