Skip to content

fix: Fully drop macOS SubclassingAdapter if KVO is detected - #835

Merged
DataTriny merged 1 commit into
mainfrom
fix-macos-subclassing-adapter-drop
Oct 23, 2026
Merged

DataTriny merged 1 commit into
mainfrom
fix-macos-subclassing-adapter-drop

Conversation

@DataTriny

@DataTriny DataTriny commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Closes #823

Unfortunately for us, macOS can sometime subclass views which then make our subclassing adapter drop implementation crash the application. One common cause is with machines that have a touch bar. The best we can do is ensure we free the adapter but don't touch the view class. Our class object will be deallocated with the view. Similarly we can't subclass a view if it is already observed, this should never happen with winit but we can't be sure and that is a limitation of the subclassing adapter.

Also introduces a testing framework for integration tests that must run on the main thread.

@bruvzg

bruvzg commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

For the reference, I think it is the same issue we have worked around on the app side in the Godot engine some time ago (I assumed it to be OS bug) - godotengine/godot#105804

@DataTriny

Copy link
Copy Markdown
Member Author

Thanks @bruvzg, I might have looked into this earlier had I come across this Godot issue. Any chance Godot can use the regular macOS, Windows and iOS adapters in the future? Such issues are a direct consequence of the hacks we have to use to make this work and it would be better to get rid of them.

@bruvzg

bruvzg commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Any chance Godot can use the regular macOS, Windows and iOS adapters in the future?

We definitely will remove this hack as soon as we are updating to a new AccessKit version.

Tested removing it. I can still reproduce the crash with 0.23.1, and can confirm this PR fixes it.

Only tested on macOS 15 VM with TouchBar-Simulator, since I do not have any Mac with touch bar (and simulator stopped working in macOS 27).

@DataTriny
DataTriny merged commit 451885c into main Oct 23, 2026
26 checks passed
@DataTriny
DataTriny deleted the fix-macos-subclassing-adapter-drop branch October 23, 2026 15:29
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 on macOS when the subclassing adapter is dropped while the view has key-value observers

2 participants