Title: [265311] trunk/Source/WebCore
Revision
265311
Author
[email protected]
Date
2020-08-05 16:21:23 -0700 (Wed, 05 Aug 2020)

Log Message

Crash in com.apple.WebKit.WebContent at com.apple.AppKit: _NSAccessibilityRemoveAllObserversAndSendDestroyedNotification
https://bugs.webkit.org/show_bug.cgi?id=215189
<rdar://problem/66561167>

Reviewed by Chris Fleizach.

AXIsolatedObject::detachPlatformWrapper was calling the wrapper's detach
method that in turn calls the system NSAccessibilityUnregisterUniqueIdForUIElement
on the secondary thread. This function is not thread safe and hence the
random crashes.
This changes AXIsolatedObject::detachPlatformWrapper to call the
wrapper's detachIsolatedObject, avoiding the above problem altogether.
The wrapper's detach remains the same that it was before isolated tree
mode was introduced, and should only run on the main thread.

* accessibility/AccessibilityObjectInterface.h:
* accessibility/isolatedtree/AXIsolatedTree.cpp:
(WebCore::AXIsolatedTree::applyPendingChanges):
* accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm:
(WebCore::AXIsolatedObject::detachPlatformWrapper):
* accessibility/mac/WebAccessibilityObjectWrapperBase.h:
* accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
(-[WebAccessibilityObjectWrapperBase detach]):
(-[WebAccessibilityObjectWrapperBase detachIsolatedObject:]):
(-[WebAccessibilityObjectWrapperBase detachAXObject]): Merged back into detach.
(-[WebAccessibilityObjectWrapperBase detachIsolatedObject]): Deleted.
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper unregisterUniqueIdForUIElement]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (265310 => 265311)


--- trunk/Source/WebCore/ChangeLog	2020-08-05 23:19:59 UTC (rev 265310)
+++ trunk/Source/WebCore/ChangeLog	2020-08-05 23:21:23 UTC (rev 265311)
@@ -1,3 +1,34 @@
+2020-08-05  Andres Gonzalez  <[email protected]>
+
+        Crash in com.apple.WebKit.WebContent at com.apple.AppKit: _NSAccessibilityRemoveAllObserversAndSendDestroyedNotification
+        https://bugs.webkit.org/show_bug.cgi?id=215189
+        <rdar://problem/66561167>
+
+        Reviewed by Chris Fleizach.
+
+        AXIsolatedObject::detachPlatformWrapper was calling the wrapper's detach
+        method that in turn calls the system NSAccessibilityUnregisterUniqueIdForUIElement
+        on the secondary thread. This function is not thread safe and hence the
+        random crashes.
+        This changes AXIsolatedObject::detachPlatformWrapper to call the
+        wrapper's detachIsolatedObject, avoiding the above problem altogether.
+        The wrapper's detach remains the same that it was before isolated tree
+        mode was introduced, and should only run on the main thread.
+
+        * accessibility/AccessibilityObjectInterface.h:
+        * accessibility/isolatedtree/AXIsolatedTree.cpp:
+        (WebCore::AXIsolatedTree::applyPendingChanges):
+        * accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm:
+        (WebCore::AXIsolatedObject::detachPlatformWrapper):
+        * accessibility/mac/WebAccessibilityObjectWrapperBase.h:
+        * accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
+        (-[WebAccessibilityObjectWrapperBase detach]):
+        (-[WebAccessibilityObjectWrapperBase detachIsolatedObject:]):
+        (-[WebAccessibilityObjectWrapperBase detachAXObject]): Merged back into detach.
+        (-[WebAccessibilityObjectWrapperBase detachIsolatedObject]): Deleted.
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper unregisterUniqueIdForUIElement]):
+
 2020-08-05  Chris Dumez  <[email protected]>
 
         Add constructor for DynamicsCompressorNode

Modified: trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h (265310 => 265311)


--- trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h	2020-08-05 23:19:59 UTC (rev 265310)
+++ trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h	2020-08-05 23:21:23 UTC (rev 265311)
@@ -542,7 +542,7 @@
     return "";
 }
 
-enum class AccessibilityDetachmentType { CacheDestroyed, ElementDestroyed, ElementChange };
+enum class AccessibilityDetachmentType { CacheDestroyed, ElementDestroyed, ElementChanged };
 
 enum class AccessibilityConversionSpace { Screen, Page };
 

Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp (265310 => 265311)


--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp	2020-08-05 23:19:59 UTC (rev 265310)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp	2020-08-05 23:21:23 UTC (rev 265311)
@@ -445,7 +445,7 @@
                 // The new IsolatedObject is a replacement for an existing object
                 // as the result of an update. Thus detach the wrapper from the
                 // existing object and attach it to the new one.
-                object->detachWrapper(AccessibilityDetachmentType::ElementDestroyed);
+                object->detachWrapper(AccessibilityDetachmentType::ElementChanged);
                 item.m_isolatedObject->attachPlatformWrapper(wrapper.get());
             }
             m_readerThreadNodeMap.remove(axID);

Modified: trunk/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm (265310 => 265311)


--- trunk/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm	2020-08-05 23:19:59 UTC (rev 265310)
+++ trunk/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm	2020-08-05 23:21:23 UTC (rev 265311)
@@ -54,9 +54,9 @@
     setWrapper(wrapper);
 }
 
-void AXIsolatedObject::detachPlatformWrapper(AccessibilityDetachmentType)
+void AXIsolatedObject::detachPlatformWrapper(AccessibilityDetachmentType detachmentType)
 {
-    [wrapper() detach];
+    [wrapper() detachIsolatedObject:detachmentType];
 }
 
 } // WebCore

Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.h (265310 => 265311)


--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.h	2020-08-05 23:19:59 UTC (rev 265310)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.h	2020-08-05 23:21:23 UTC (rev 265311)
@@ -55,6 +55,9 @@
 #endif
 
 - (void)detach;
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+- (void)detachIsolatedObject:(WebCore::AccessibilityDetachmentType)detachmentType;
+#endif
 
 @property (nonatomic, assign) WebCore::AXID identifier;
 

Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm (265310 => 265311)


--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm	2020-08-05 23:19:59 UTC (rev 265310)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm	2020-08-05 23:21:23 UTC (rev 265311)
@@ -311,30 +311,21 @@
 }
 #endif
 
-- (void)detachAXObject
+- (void)detach
 {
+    ASSERT(isMainThread());
+    _identifier = InvalidAXID;
     m_axObject = nullptr;
 }
 
 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
-- (void)detachIsolatedObject
+- (void)detachIsolatedObject:(AccessibilityDetachmentType)detachmentType
 {
+    ASSERT_UNUSED(detachmentType, detachmentType == AccessibilityDetachmentType::ElementChanged ? _identifier != InvalidAXID && m_axObject : true);
     m_isolatedObject = nullptr;
 }
 #endif
 
-- (void)detach
-{
-    _identifier = InvalidAXID;
-#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
-    if (AXObjectCache::isIsolatedTreeEnabled()) {
-        [self detachIsolatedObject];
-        return;
-    }
-#endif
-    [self detachAXObject];
-}
-
 - (WebCore::AXCoreObject*)updateObjectBackingStore
 {
     // Calling updateBackingStore() can invalidate this element so self must be retained.

Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (265310 => 265311)


--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm	2020-08-05 23:19:59 UTC (rev 265310)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm	2020-08-05 23:21:23 UTC (rev 265311)
@@ -542,6 +542,7 @@
 
 - (void)unregisterUniqueIdForUIElement
 {
+    ASSERT(isMainThread());
     NSAccessibilityUnregisterUniqueIdForUIElement(self);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to