Skip to content

Fix VST plugin window crash on macOS when closing#32745

Merged
igorkorsukov merged 1 commit intomusescore:masterfrom
CubikingChill:fix-vst-crash
Mar 24, 2026
Merged

Fix VST plugin window crash on macOS when closing#32745
igorkorsukov merged 1 commit intomusescore:masterfrom
CubikingChill:fix-vst-crash

Conversation

@CubikingChill
Copy link
Copy Markdown
Contributor

Problem

MuseScore crashes when closing VST plugin windows (e.g., ARIA player) on macOS. The crash occurs with a segmentation fault during the window close sequence.

Platform: macOS only

Root Cause

The crash is caused by calling IPlugView::removed() during the closeEvent() on macOS. When the window closes, macOS's Cocoa framework may already be deallocating the NSView as part of its own cleanup sequence. Calling removed() at this point attempts to interact with partially or fully deallocated NSView objects, resulting in a crash.

This is a platform-specific issue:

  • macOS (NSView): The native view may already be in the process of deallocation when closeEvent() is triggered, making removed() unsafe
  • Windows (HWND): Window handles remain valid throughout the close event
  • Linux (X11): X11 window IDs remain valid throughout the close event

Solution

Skip calling IPlugView::removed() on macOS using #ifndef Q_OS_MAC. The NSView cleanup is handled automatically by the Cocoa framework during window destruction, so the explicit removed() call is unnecessary and harmful on macOS.

On Windows and Linux, removed() continues to be called to ensure proper plugin cleanup.

Changes

Modified two files:

  1. src/framework/vst/widgets/vstviewdialog_qwidget.cpp - QWidget-based VST dialog
  2. src/framework/vst/qml/Muse/Vst/vstview.cpp - QML-based VST view

Both deinit() methods now conditionally skip m_view->removed() on macOS.

Testing

  • Verify VST plugins (especially ARIA) can be opened and closed without crashing on macOS
  • Verify VST plugins continue to work correctly on Windows and Linux
  • Verify no memory leaks or resource issues on any platform

Resolves: #32742

  • I signed the CLA
  • The title of the PR describes the problem it addresses
  • Each commit's message describes its purpose and effects, and references the issue it resolves
  • If changes are extensive, there is a sequence of easily reviewable commits
  • The code in the PR follows the coding rules
  • There are no unnecessary changes
  • The code compiles and runs on my machine, preferably after each commit individually
  • I created a unit test or vtest to verify the changes I made (if applicable)

Fixes musescore#32742

The crash occurred when closing VST plugin windows (e.g., ARIA) on macOS.
The issue was that IPlugView::removed() was being called during window
closure, which tries to access NSView objects that macOS may already be
deallocating as part of its own cleanup sequence.

On macOS, the Cocoa framework handles NSView cleanup automatically during
window destruction. Calling removed() at this point causes a crash because
it attempts to interact with partially or fully deallocated NSView objects.

On Windows and Linux, the underlying window handles (HWND/X11) remain valid
throughout the close event, so calling removed() is safe and necessary for
proper plugin cleanup.

The fix skips the removed() call on macOS using #ifndef Q_OS_MAC, allowing
the system to handle NSView cleanup naturally while maintaining proper
cleanup on other platforms.

This bug was introduced in commit d50a9bd (Dec 2022) when deinit() was
added to closeEvent() to fix issue musescore#13867.
@igorkorsukov igorkorsukov merged commit 3c6133b into musescore:master Mar 24, 2026
12 checks passed
@Jojo-Schmitz
Copy link
Copy Markdown
Contributor

Jojo-Schmitz commented Mar 24, 2026

Seems needed for 4.7 too, right??

@RomanPudashkin
Copy link
Copy Markdown
Contributor

Seems needed for 4.7 too, right??

We need to test it first. I'll port it myself later

@CubikingChill
Copy link
Copy Markdown
Contributor Author

CubikingChill commented Apr 6, 2026

2026-04-06.16-47-04.mp4

Tested on MacOS Sequoia in a x86 VM, using latest nightly and latest version of ARIA player

@RomanPudashkin RomanPudashkin mentioned this pull request Apr 7, 2026
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.

Crash when closing ARIA VST window (macOS)

4 participants