[win] Chrome freezes (when accessibility is generated for large pages?)

144 views
Skip to first unread message

Carlos Lenz

unread,
Aug 18, 2021, 4:29:22 PM8/18/21
to Chromium Accessibility
Hi,

I'm using CUIAutomation to extract minor data from Chrome's tool bar (not the page itself).

The problem is that once I try accessing anything but the window itself, if the page is large like https://chromium.googlesource.com/chromium/src/+/refs/heads/main/ui/accessibility/platform/ax_platform_node_win.cc, it takes a lot of time (4s) and all Chrome windows freeze after I try changing Chrome tabs. Sometimes the whole system also slows down.

After reading https://www.chromium.org/developers/design-documents/accessibility, my guess is that Accessibility is being generated for the entire page.

At the same time, I can inspect Chrome using Accessibility Insights for Windows and it works just fine. So there should be a way to avoid this problem.

- Is it a bug?
- Are there other APIs that I can use that avoid this problem?

Environment

Chrome: 92.0.4515.159 (64 bit)
Windows: 10.0.19043 Build 19043
CPU: i7-9750H
Memory: 32.0 GB

// VS 2017 Test Code:

#include <cassert>
#include <chrono>
#include <ios>
#include <iostream>
#include <windows.h>
#include <uiautomationclient.h>
#include <comutil.h>

#ifdef _DEBUG
# pragma comment(lib, "comsuppwd.lib")
#else
# pragma comment(lib, "comsuppw.lib")
#endif
# pragma comment(lib, "wbemuuid.lib")

int main()
{
HRESULT hr = CoInitialize(NULL);
assert(SUCCEEDED(hr));

IUIAutomation *pAutomation;
hr = CoCreateInstance(
__uuidof(CUIAutomation),
NULL,
CLSCTX_INPROC_SERVER,
__uuidof(IUIAutomation),
(void **)(&pAutomation)
);
assert(SUCCEEDED(hr));

std::cout << "Go to window..." << std::endl;
Sleep(2000);

HWND hWin = GetForegroundWindow();
assert(hWin != NULL);

std::cout << "Running..." << std::endl;

IUIAutomationElement *win;
hr = pAutomation->ElementFromHandle(hWin, &win);
assert(hWin != NULL);

VARIANT varCtrlL;
varCtrlL.vt = VT_BSTR;
varCtrlL.bstrVal = _com_util::ConvertStringToBSTR("Ctrl+L");

IUIAutomationCondition *ctrlLAccessKeyCondition = NULL;
hr = pAutomation->CreatePropertyCondition(UIA_AccessKeyPropertyId, varCtrlL, &ctrlLAccessKeyCondition);
assert(SUCCEEDED(hr));

IUIAutomationElement *address;

std::chrono::steady_clock::time_point before = std::chrono::steady_clock::now();
hr = win->FindFirst(
TreeScope_Descendants,
ctrlLAccessKeyCondition,
&address
);
std::chrono::steady_clock::time_point after = std::chrono::steady_clock::now();
std::cout << "Took "
<< (std::chrono::duration_cast<std::chrono::milliseconds>(after - before).count())
<< " ms"
<< std::endl;

assert(SUCCEEDED(hr));
}

Reply all
Reply to author
Forward
0 new messages