Skip to content

Backport Chromium fix for wrong macOS AX line number / line range (crbug 423048796) to 42-x-y and 43-x-y #53403

Closed

Description

@robin24

Preflight Checklist

Electron Version

42.8.1 (also 42.10.0 and 43.5.1; fixed in 44.0.0)

What operating system(s) are you using?

macOS

Operating System Version

macOS 27.0 (26A5425a); also reproduced on macOS 15 and 26 by other users

What arch are you using?

arm64 (including Apple Silicon)

Last Known Working Electron version

34.x (Chromium 132) for the line range; the line number has been wrong for longer

Does the issue also appear in Chromium / Google Chrome?

No

Expected Behavior

With VoiceOver and a Braille display, moving the caret with Up/Down Arrow or Return in a multi-line text field (<textarea> or div[role=textbox]) shows the current line on the Braille display, starting at its first character.

Through the macOS Accessibility API: AXLineForIndex(caret) returns the line containing the caret, and AXRangeForLine(n) returns the range of line n for every line.

Actual Behavior

The Braille display shows the previous line joined to the current one, keeps showing the old line, or goes blank. Only the first line of the field is ever shown correctly. This makes Electron apps unusable with a Braille display on macOS (for example VS Code, see microsoft/vscode#319725 and microsoft/vscode#316018).

Through the macOS Accessibility API, unless the caret is at the very start of a line, AXLineForIndex returns the next line's number and AXRangeForLine returns nothing for every line except line 0.

This is the bug from #47393, which was closed as upstream. The upstream fix has landed: https://crbug.com/423048796, Chromium commit 36ac8f31796a392340f7914d1018c3a885fc183f (https://chromium-review.googlesource.com/c/chromium/src/+/8092671), first shipped in Chromium 152 (Electron 44). Neither 42-x-y nor 43-x-y carries it. Request: backport that commit to 42-x-y and 43-x-y.

Testcase Gist URL

https://gist.github.com/godbout/a0cf7b46e4032790bb22281f9cdb39a4

Additional Information

The gist above is the Fiddle from #47393 and reproduces this exact bug. Any multi-line text field shows it.

In-depth investigation

Same test page, same VoiceOver, same Braille display, queried through the macOS Accessibility API with the caret in the middle of line 2 of a three-line text.

Electron 42.8.1 / Chromium 148 (VS Code 1.135):

AXValue: "This is test line 1\nThis is test line 2\nThis is test line 3"
AXSelectedTextRange: {25, 0}
AXInsertionPointLineNumber: 1          (correct, 0-based)
AXLineForIndex(25) = 2                 (wrong: one line too far)
AXRangeForLine(0) = {0, 20} "This is test line 1\n"
AXRangeForLine(1), AXRangeForLine(2): no result
AXLineForIndex for every index: 0:0 1:1 ... 19:1 20:1 21:2 ... 40:2 41:3 ... 58:3

Google Chrome 152.0.7977.66 (contains the fix):

AXValue: "This is line 1\nThis is line 2\nThis is line 3"
AXSelectedTextRange: {20, 0}
AXInsertionPointLineNumber: 1
AXLineForIndex(20) = 1                 (correct)
AXRangeForLine(0) = {0, 15}  "This is line 1\n"
AXRangeForLine(1) = {15, 15} "This is line 2\n"
AXRangeForLine(2) = {30, 14} "This is line 3"
AXLineForIndex for every index: 0:0 1:0 ... 14:0 15:1 ... 29:1 30:2 ... 43:2

Cause, from the Chromium sources at the revisions Electron ships:

  • ui/accessibility/platform/browser_accessibility_cocoa.mm, accessibilityLineForIndex: used std::lower_bound over kLineStarts (which includes offset 0), so every index that is not exactly a line start maps to the following line. The fix uses upper_bound minus one with bounds checks.
  • ui/accessibility/platform/ax_platform_node_cocoa.mm, AXRangeForLine: (the legacy parameterized-attribute path, which is still the active one because kMacAccessibilityAPIMigration is disabled by default) returned nil for any line index other than 0 since the migration change in Chromium 134 (Electron 35). The fix forwards every line index to accessibilityRangeForLine:.
  • The upstream commit is small and self-contained (two files plus a test), so it should backport cleanly to 42-x-y and 43-x-y.

Activity

  1. github-actions commented on Sep 2, 2026

    @github-actions
    Contributor

    Hello @robin24. Thanks for taking the time to open an issue and helping to make Electron better!

    This issue was automatically closed because its body does not follow any of this repository's issue templates. Maintainers rely on the sections in those templates to triage issues, and issues that are missing them usually cannot be acted upon.

    To get this issue triaged, please either:

  2. MarshallOfSound commented on Sep 2, 2026

    @MarshallOfSound
    Member

    I can look at backporting to 43, 42-x-y is in security-fix-only state right now

  3. MarshallOfSound commented on Sep 3, 2026

    @MarshallOfSound
    Member

    Done in #53428

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions