Browse Source

Fix off-thread accessibility hit-test crash on macOS (#21779)

* Fix off-thread accessibility hit-test crash on macOS

GetAutomationPeer() returns null when called off the UI thread, but
-[AvnWindow automationPeer] called SetNode on it without checking, which
segfaults. Guard against the null peer so it returns nil instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Removed comment

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
pull/21812/head
Victor Chelaru 2 months ago
committed by GitHub
parent
commit
f8dd4248ca
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 12
      native/Avalonia.Native/src/OSX/AvnWindow.mm
  2. 2
      native/Avalonia.Native/src/OSX/WindowProtocol.h

12
native/Avalonia.Native/src/OSX/AvnWindow.mm

@ -628,14 +628,18 @@
return GetNSStringAndRelease(automationPeer->GetAutomationId());
}
- (IAvnAutomationPeer* _Nonnull) automationPeer
- (IAvnAutomationPeer* _Nullable) automationPeer
{
auto parent = _parent.tryGet();
if (parent && _automationPeer == nullptr)
{
_automationPeer = parent->BaseEvents->GetAutomationPeer();
_automationNode = new AvnAutomationNode(self);
_automationPeer->SetNode(_automationNode);
auto peer = parent->BaseEvents->GetAutomationPeer();
if (peer != nullptr)
{
_automationPeer = peer;
_automationNode = new AvnAutomationNode(self);
_automationPeer->SetNode(_automationNode);
}
}
return _automationPeer;

2
native/Avalonia.Native/src/OSX/WindowProtocol.h

@ -17,7 +17,7 @@ struct IAvnAutomationPeer;
-(void) showAppMenuOnly;
-(void) showWindowMenuWithAppMenu;
-(void) applyMenu:(AvnMenu* _Nullable)menu;
-(IAvnAutomationPeer* _Nonnull) automationPeer;
-(IAvnAutomationPeer* _Nullable) automationPeer;
-(double) getExtendedTitleBarHeight;
-(void) setIsExtended:(bool)value;

Loading…
Cancel
Save