Title: [285671] trunk/Tools
- Revision
- 285671
- Author
- [email protected]
- Date
- 2021-11-11 14:46:30 -0800 (Thu, 11 Nov 2021)
Log Message
Fix for thread deadlocks during layout tests in isolated tree mode.
https://bugs.webkit.org/show_bug.cgi?id=232999
<rdar://problem/85300861>
Reviewed by Chris Fleizach.
In isolated tree mode, AccessibilityUIElement calls into the AX API are
dispatched to a secondary, mocked thread created by the
AccessibilityController to simulate AT requests off of the main thread.
The main thread, in which all AccessibilityUIElement methods are run,
is blocked to wait for the results from the AX thread, to then continue
execution of JS layout tests.
The deadlocks arise when the AX API call cannot be fulfilled on the
secondary thread and needs to be dispatched to the main thread that is
now blocked. The main thread is waitng for the AccessibilityController's
secondary mocked thread, and that thread is waitng for the main thread
to compute results for the AX API request.
This patch introduces a workaround by spinning the main thread run loop
right after the API calls are dispatched to the AX thread.
* WebKitTestRunner/InjectedBundle/AccessibilityController.cpp:
(WTR::AccessibilityController::executeOnAXThreadAndWait):
(WTR::AccessibilityController::spinMainRunLoop const):
* WebKitTestRunner/InjectedBundle/AccessibilityController.h:
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (285670 => 285671)
--- trunk/Tools/ChangeLog 2021-11-11 22:43:51 UTC (rev 285670)
+++ trunk/Tools/ChangeLog 2021-11-11 22:46:30 UTC (rev 285671)
@@ -1,3 +1,30 @@
+2021-11-11 Andres Gonzalez <[email protected]>
+
+ Fix for thread deadlocks during layout tests in isolated tree mode.
+ https://bugs.webkit.org/show_bug.cgi?id=232999
+ <rdar://problem/85300861>
+
+ Reviewed by Chris Fleizach.
+
+ In isolated tree mode, AccessibilityUIElement calls into the AX API are
+ dispatched to a secondary, mocked thread created by the
+ AccessibilityController to simulate AT requests off of the main thread.
+ The main thread, in which all AccessibilityUIElement methods are run,
+ is blocked to wait for the results from the AX thread, to then continue
+ execution of JS layout tests.
+ The deadlocks arise when the AX API call cannot be fulfilled on the
+ secondary thread and needs to be dispatched to the main thread that is
+ now blocked. The main thread is waitng for the AccessibilityController's
+ secondary mocked thread, and that thread is waitng for the main thread
+ to compute results for the AX API request.
+ This patch introduces a workaround by spinning the main thread run loop
+ right after the API calls are dispatched to the AX thread.
+
+ * WebKitTestRunner/InjectedBundle/AccessibilityController.cpp:
+ (WTR::AccessibilityController::executeOnAXThreadAndWait):
+ (WTR::AccessibilityController::spinMainRunLoop const):
+ * WebKitTestRunner/InjectedBundle/AccessibilityController.h:
+
2021-11-11 Rachel Ginsberg <[email protected]>
Add support in WebCore for web app manifest icons
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.cpp (285670 => 285671)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.cpp 2021-11-11 22:43:51 UTC (rev 285670)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.cpp 2021-11-11 22:46:30 UTC (rev 285671)
@@ -104,12 +104,18 @@
{
#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
if (m_useMockAXThread) {
- AXThread::dispatch([&function, this] {
+ bool complete = false;
+ AXThread::dispatch([&function, &complete] {
function();
- m_semaphore.signal();
+ complete = true;
});
- m_semaphore.wait();
+ // Spin the main run loop so that any required DOM processing can be
+ // executed in the main thread. That is the case of most parameterized
+ // attributes, where the attribute value has to be calculated back in
+ // the main thread.
+ while (!complete)
+ spinMainRunLoop();
} else
#endif
function();
@@ -138,6 +144,15 @@
function();
});
}
+
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+void AccessibilityController::spinMainRunLoop() const
+{
+ ASSERT(isMainThread());
+ CFRunLoopRunInMode(kCFRunLoopDefaultMode, .01, false);
+}
+#endif // ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+
#endif // PLATFORM(COCOA)
RefPtr<AccessibilityUIElement> AccessibilityController::elementAtPoint(int x, int y)
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.h (285670 => 285671)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.h 2021-11-11 22:43:51 UTC (rev 285670)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.h 2021-11-11 22:46:30 UTC (rev 285671)
@@ -35,7 +35,6 @@
#include <wtf/RetainPtr.h>
#endif
#include <wtf/Threading.h>
-#include <wtf/threads/BinarySemaphore.h>
#if USE(ATK)
#include "AccessibilityNotificationHandlerAtk.h"
@@ -105,6 +104,7 @@
void updateIsolatedTreeMode();
#if PLATFORM(COCOA)
+ void spinMainRunLoop() const;
// _AXUIElementUseSecondaryAXThread and _AXUIElementRequestServicedBySecondaryAXThread
// do not work for WebKitTestRunner since this is calling directly into
// WebCore/accessibility via _javascript_ without going through HIServices.
@@ -112,7 +112,6 @@
bool m_useMockAXThread { false };
#endif
bool m_accessibilityIsolatedTreeMode { false };
- BinarySemaphore m_semaphore;
#endif
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes