From 7f28424f864523f2b3ea2152d4686683bb03bd88 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 27 Apr 2017 18:06:46 +0200 Subject: Disable accessibility support on Linux by default For very big HTML pages, accessibility support can slow down the loading and rendering of pages due to creation of many AXNodes for every DOM node, and a lot of serializing and deserializing between processes. Because accessibility is almost always enabled on Linux, and there is no way to query if an accessibility feature was explicitly requested, Qt WebEngine accessibility support on Linux will be disabled by default. Users can set the QTWEBENGINE_ENABLE_LINUX_ACCESSIBILITY environment variable to re-enable accessibility support on Linux. [ChangeLog][Accessibility][Linux] Accessibility is disabled by default for Qt WebEngine on Linux. Task-number: QTBUG-59922 Task-number: QTBUG-54650 Change-Id: Ib0454f6f753043838e4ecf2227d2249afc15a6ef Reviewed-by: Kai Koehne --- src/core/render_widget_host_view_qt.cpp | 21 ++++++++++++++++++--- .../doc/src/qtwebengine-platform-notes.qdoc | 20 ++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 6568398a8..72abe04af 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -237,6 +237,19 @@ private: float dpiScale; }; +bool isAccessibilityEnabled() { + // On Linux accessibility is disabled by default due to performance issues, + // and can be re-enabled by setting the QTWEBENGINE_ENABLE_LINUX_ACCESSIBILITY environment + // variable. For details, see QTBUG-59922. +#ifdef Q_OS_LINUX + static bool accessibility_enabled + = qEnvironmentVariableIsSet("QTWEBENGINE_ENABLE_LINUX_ACCESSIBILITY"); +#else + const bool accessibility_enabled = true; +#endif + return accessibility_enabled; +} + RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost* widget) : m_host(content::RenderWidgetHostImpl::From(widget)) , m_gestureProvider(QtGestureProviderConfig(), this) @@ -260,9 +273,11 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost* widget { m_host->SetView(this); #ifndef QT_NO_ACCESSIBILITY - QAccessible::installActivationObserver(this); - if (QAccessible::isActive()) - content::BrowserAccessibilityStateImpl::GetInstance()->EnableAccessibility(); + if (isAccessibilityEnabled()) { + QAccessible::installActivationObserver(this); + if (QAccessible::isActive()) + content::BrowserAccessibilityStateImpl::GetInstance()->EnableAccessibility(); + } #endif // QT_NO_ACCESSIBILITY auto* task_runner = base::ThreadTaskRunnerHandle::Get().get(); m_beginFrameSource.reset(new cc::DelayBasedBeginFrameSource( diff --git a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc index 06a4a53a9..57e3ce6a8 100644 --- a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc +++ b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc @@ -161,4 +161,24 @@ set to 1 or alternatively the \c{--no-sandbox} command line argument can be passed to the user application executable. + \section1 Accessibility and Performance + + Qt WebEngine enables accessibility support for web pages when the following conditions + are met: + + \list + \li Qt Core is configured and built with accessibility support enabled. + \li The QPA plugin is notified by the operating system that accessibility should be + activated. This happens for example when using a screen reader application on Windows + or VoiceOver on \macos. + \endlist + + Due to some limitations, the Linux QPA plugin almost always reports that accessibility should + be activated. On big HTML pages, this can cause a significant slowdown in rendering speed. + + Because of that, from Qt 5.9 onwards, Qt WebEngine accessibility support is disabled by default + on Linux. + It can be re-enabled by setting the \c QTWEBENGINE_ENABLE_LINUX_ACCESSIBILITY environment + variable to a non-empty value. + */ -- cgit v1.2.3