Reland "Reset accessibility on AXMode update"

This is a reland of commit be82cef6def900567e84acd2ea15459217cf2cad.

It had been reverted as a suspected cause of crbug.com/1364487, and the
revert did improve the end-user experience, but did not completely fix
the regression. Further investigation showed that the underlying problem
was due to commit 78735e3dbdb9953bf0a7d31ca92a75c85bf7f40c and
commit 435c9adbf2dea21ff7503148d6b145849718bab8, both of which have
since been reverted. See crbug.com/1379174.

Regarding the specific issue found in crbug.com/1364487, two additional
changes were made: crrev.com/c/3974532 increases the accessibility-API
usage delay from one to five seconds in order to reduce the frequency
with which we update the Active/Inactive time, and crrev.com/c/3982256
delays disabling accessibility support in response to a client being
terminated.

With all of the above changes in place, it should be safe to reland this
change.

AX-Relnotes: n/a

Bug: 1341507

Original change's description:
> Reset accessibility on AXMode update
>
> This change more strictly performs cleanup when accessibility is turned
> off within the browser process.
>
> Specifically, when an AXMode turns off web content accessibility, we will
> destroy BrowserAccessibilityManager. This object would otherwise occupy a
> non-trivial amount of memory.
>
> A speculative benefit of this would be to tighten our assumptions about
> the lifetime of BAM. For instance, if an owning RFHI is reused and
> somehow accessibility is turned back on, we would potentially apply tree
> updates on a stale BAM.
>
> BrowserAccessibilityManager::DetachFromParent is required because of hitting
>
> FATAL:browser_accessibility_manager.cc(1761)] Check failed: parent || !connected_to_parent_tree_node_.
> 3   Chromium Framework                  0x000000012bd6749e logging::LogMessage::~LogMessage() + 14
> 4   Chromium Framework                  0x00000001281291eb content::BrowserAccessibilityManager::GetParentManager() const + 379
> 5   Chromium Framework                  0x000000012812d427 content::BrowserAccessibilityManager::GetParentNodeFromParentTreeAsAXNode() const + 23
> 6   Chromium Framework                  0x000000012812841b content::BrowserAccessibilityManager::GetParentNodeFromParentTree() const + 27
> 7   Chromium Framework                  0x0000000128128263 content::BrowserAccessibilityManager::~BrowserAccessibilityManager() + 67
> 8   Chromium Framework                  0x0000000128a81074 content::BrowserAccessibilityManagerMac::~BrowserAccessibilityManagerMac() + 68
> 9   Chromium Framework                  0x00000001287b3c39 content::RenderFrameHostImpl::UpdateAccessibilityMode() + 281
> 10  Chromium Framework                  0x00000001287c9bcd base::internal::Invoker<base::internal::BindState<base::RepeatingCallback<content::RenderFrameHost::FrameIterationAction (content::RenderFrameHostImpl*)> content::RenderFrameHostImpl::FrameIterationWrapper<content::RenderFrameHostImpl>(base::RepeatingCallback<void (content::RenderFrameHostImpl*)>)::'lambda'(base::RepeatingCallback<void (content::RenderFrameHostImpl*)>, content::RenderFrameHostImpl*), base::RepeatingCallback<void (content::RenderFrameHostImpl*)>>, content::RenderFrameHost::FrameIterationAction (content::RenderFrameHostImpl*)>::Run(base::internal::BindStateBase*, content::RenderFrameHostImpl*) + 93
> 11  Chromium Framework                  0x000000012878af9b content::RenderFrameHostImpl::ForEachRenderFrameHostImpl(base::RepeatingCallback<content::RenderFrameHost::FrameIterationAction (content::RenderFrameHostImpl*)>, bool) + 635
> 12  Chromium Framework                  0x000000012878b30c content::RenderFrameHostImpl::ForEachRenderFrameHostIncludingSpeculative(base::RepeatingCallback<void (content::RenderFrameHostImpl*)>) + 124
> 13  Chromium Framework                  0x00000001289a20e2 content::WebContentsImpl::SetAccessibilityMode(ui::AXMode) + 178
> 14  Chromium Framework                  0x0000000128132661 content::BrowserAccessibilityStateImpl::ResetAccessibilityMode() + 113
> 15  Chromium Framework                  0x000000012b740465 -[BrowserCrApplication accessibilitySetValue:forAttribute:] + 101
> 16  AppKit                              0x00007ff80eb3153a -[NSAccessibilityAttributeAccessorInfo setAttributeValueForObject:withValue:] + 58
>
> Bug: 1341507
> Test: cq
> AX-Relnotes: n/a
>
> Change-Id: I97fb1f5b24456b024d3d9b1960c35512d5277758
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3758895
> Commit-Queue: David Tseng <dtseng@chromium.org>
> Reviewed-by: Abigail Klein <abigailbklein@google.com>
> Reviewed-by: Alexander Timin <altimin@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1024942}

Change-Id: Id3a98f8f9dfee6cc137022be21349e58ad954b6f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4008398
Reviewed-by: Abigail Klein <abigailbklein@google.com>
Commit-Queue: Joanmarie Diggs <jdiggs@igalia.com>
Reviewed-by: David Tseng <dtseng@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1069898}
3 files changed
tree: 48f59e51635341e211a1726d38c7804a4c70848a
  1. android_webview/
  2. apps/
  3. ash/
  4. base/
  5. build/
  6. build_overrides/
  7. buildtools/
  8. cc/
  9. chrome/
  10. chromecast/
  11. chromeos/
  12. codelabs/
  13. components/
  14. content/
  15. courgette/
  16. crypto/
  17. dbus/
  18. device/
  19. docs/
  20. extensions/
  21. fuchsia_web/
  22. gin/
  23. google_apis/
  24. google_update/
  25. gpu/
  26. headless/
  27. infra/
  28. ios/
  29. ipc/
  30. media/
  31. mojo/
  32. native_client_sdk/
  33. net/
  34. pdf/
  35. ppapi/
  36. printing/
  37. remoting/
  38. rlz/
  39. sandbox/
  40. services/
  41. skia/
  42. sql/
  43. storage/
  44. styleguide/
  45. testing/
  46. third_party/
  47. tools/
  48. ui/
  49. url/
  50. weblayer/
  51. .clang-format
  52. .clang-tidy
  53. .eslintrc.js
  54. .git-blame-ignore-revs
  55. .gitattributes
  56. .gitignore
  57. .gn
  58. .mailmap
  59. .rustfmt.toml
  60. .vpython3
  61. .yapfignore
  62. AUTHORS
  63. BUILD.gn
  64. CODE_OF_CONDUCT.md
  65. codereview.settings
  66. DEPS
  67. DIR_METADATA
  68. ENG_REVIEW_OWNERS
  69. LICENSE
  70. LICENSE.chromium_os
  71. OWNERS
  72. PRESUBMIT.py
  73. PRESUBMIT_test.py
  74. PRESUBMIT_test_mocks.py
  75. README.md
  76. WATCHLISTS
README.md

Logo Chromium

Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.

The project's web site is https://www.chromium.org.

To check out the source code locally, don't use git clone! Instead, follow the instructions on how to get the code.

Documentation in the source is rooted in docs/README.md.

Learn how to Get Around the Chromium Source Code Directory Structure .

For historical reasons, there are some small top level directories. Now the guidance is that new top level directories are for product (e.g. Chrome, Android WebView, Ash). Even if these products have multiple executables, the code should be in subdirectories of the product.

If you found a bug, please file it at https://crbug.com/new.