Skip to content

Commit ea74f46

Browse files
Avoid premature atspi interactions during initialization
Currently, when the system is starting up, it will perform the atspi related initializations to allow clients to connect. When a client connects, the accessibility object cache is enabled via a call to AXObjectCache::enableAccessibility(). On certain platforms, a client may connect only if accesibility support is enabled via a user configurable menu option (e.g. to enable/disable voice guidance) to minimize unnecessary D-Bus traffic. Consequently, the accessibility object cache may not be enabled when the page loads and no accessibility related information will be gathered. If the user enables accessibility without effectively leaving the browser (e.g. remote control shortcut), accessibility will not be operational on the currently loaded page. A page reload would be required or changes to the DOM tree, which may not happen depending on the app design (at least while on the page the user is navigating on). To overcome this, the accessibility cache may be enabled by default (via custom patch). This leads to a race condition between the atspi init sequence waiting to take ownership of the bus name, and the page load causing state changes that lead to attempts to register objects: AccessibilityAtspi::stateChanged() -> AccessibilityObjectAtspi::path () -> AccessibilityObjectAtspi::registerObject() -> AccessibilityAtspi::registerObject() -> RELEASE_ASSERT(!m_isConnecting); To overcome this, we'll consider the connection as established to allow method calls to complete only after acquiring the bus name. Signed-off-by: Filipe Norte <filipe_norte@comcast.com>
1 parent 6ba89b2 commit ea74f46

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

Source/WebCore/accessibility/atspi/AccessibilityAtspi.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ void AccessibilityAtspi::connect(const String& busAddress, const String& busName
7575

7676
void AccessibilityAtspi::didConnect(GRefPtr<GDBusConnection>&& connection)
7777
{
78-
m_connection = WTFMove(connection);
79-
if (!m_connection) {
78+
m_pendingConnection = WTFMove(connection);
79+
if (!m_pendingConnection) {
8080
m_isConnecting = false;
8181
return;
8282
}
8383

8484
RELEASE_ASSERT(g_dbus_is_name(m_busName.utf8().data()));
85-
g_bus_own_name_on_connection(m_connection.get(), m_busName.utf8().data(), G_BUS_NAME_OWNER_FLAGS_DO_NOT_QUEUE,
85+
g_bus_own_name_on_connection(m_pendingConnection.get(), m_busName.utf8().data(), G_BUS_NAME_OWNER_FLAGS_DO_NOT_QUEUE,
8686
[](GDBusConnection*, const char*, gpointer userData) {
8787
auto& atspi = *static_cast<AccessibilityAtspi*>(userData);
8888
atspi.didOwnName();
@@ -93,6 +93,7 @@ void AccessibilityAtspi::didConnect(GRefPtr<GDBusConnection>&& connection)
9393
void AccessibilityAtspi::didOwnName()
9494
{
9595
m_isConnecting = false;
96+
m_connection = WTFMove(m_pendingConnection);
9697

9798
for (auto& pendingRegistration : m_pendingRootRegistrations)
9899
registerRoot(pendingRegistration.root, WTFMove(pendingRegistration.interfaces), WTFMove(pendingRegistration.completionHandler));

Source/WebCore/accessibility/atspi/AccessibilityAtspi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class AccessibilityAtspi {
132132
String m_busName;
133133
bool m_isConnecting { false };
134134
GRefPtr<GDBusConnection> m_connection;
135+
GRefPtr<GDBusConnection> m_pendingConnection;
135136
GRefPtr<GDBusProxy> m_registry;
136137
Vector<PendingRootRegistration> m_pendingRootRegistrations;
137138
HashMap<CString, Vector<GUniquePtr<char*>>> m_eventListeners;

0 commit comments

Comments
 (0)