Skip to content

[stable] Fix AccessibilityBridge startup crash on vendor-modified Android - #189759

Merged
auto-submit[bot] merged 4 commits into
flutter:flutter-3.44-candidate.0from
Joyatou:cp/184630-fix-accessibility-bridge
Jul 23, 2026
Merged

auto-submit[bot] merged 4 commits into
flutter:flutter-3.44-candidate.0from
Joyatou:cp/184630-fix-accessibility-bridge

Conversation

@Joyatou

@Joyatou Joyatou commented Jul 21, 2026

Copy link
Copy Markdown

Cherry-picks #184630 (fixes #184286) to flutter-3.44-candidate.0.

Impacted Users

Devices on vendor-modified Android 11 ROMs that report SDK_INT >= 31 but ship a Configuration class without the API-31 fontWeightAdjustment field. Confirmed in production on OnePlus 8 Pro (Android 11); the OnePlus/Oppo/Realme ROM family is the likely blast radius. #184286 cited 95 fatal events, 100% OnePlus 8 Pro / Android 11.

Impact Description

Hard crash at startup. NoSuchFieldError is thrown from AccessibilityBridge.setBoldTextFlag inside the AccessibilityBridge constructor during FlutterActivity.onCreate, so the process dies before any Dart runs — the app never opens on affected devices.

Workaround

None from app code. The field read happens inside the engine's AccessibilityBridge constructor before the Dart isolate starts, so the embedding app cannot guard or catch it.

Risk

Low. +20/-4 in a single file (AccessibilityBridge.java): moves the fontWeightAdjustment read into an @RequiresApi(31) Api31Impl inner class so ART's class verifier no longer eagerly resolves the field at class-load time on older or vendor-modified runtimes. Mirrors the hardening AndroidX Compose applied for the same crash (AOSP b/353988277). Only touches the already-failing path.

Test Coverage

No automated test — the trigger is a device/ROM-specific NoSuchFieldError that isn't reproducible in CI. The change is defensive and validated against the production crash signature in #184286.

Validation Steps

Launch the app on an affected device (OnePlus 8 Pro / Android 11). Before: immediate startup crash. After: app launches normally; bold-text accessibility is simply treated as unavailable.

@Joyatou
Joyatou requested a review from a team as a code owner July 21, 2026 04:21
@Joyatou
Joyatou requested review from mboetger and removed request for a team July 21, 2026 04:21
@flutter-dashboard

Copy link
Copy Markdown

This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter.

Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed.

@github-actions github-actions Bot added the platform-android Android applications specifically label Jul 21, 2026
@google-cla

google-cla Bot commented Jul 21, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. team-android Owned by Android platform team labels Jul 21, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request isolates API-31 field references in AccessibilityBridge.java into a static inner class Api31Impl to prevent class verification crashes on older Android versions. The review feedback suggests wrapping the field access in Api31Impl.isBoldText with a try-catch block for NoSuchFieldError to handle vendor-modified ROMs that might lack the field despite reporting API level 31 or higher.

Comment on lines +3269 to +3273
static boolean isBoldText(Configuration configuration) {
int fontWeightAdjustment = configuration.fontWeightAdjustment;
return fontWeightAdjustment != Configuration.FONT_WEIGHT_ADJUSTMENT_UNDEFINED
&& fontWeightAdjustment >= BOLD_TEXT_WEIGHT_ADJUSTMENT;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To make this implementation extremely robust against vendor-modified ROMs that might report SDK_INT >= 31 but lack the fontWeightAdjustment field or FONT_WEIGHT_ADJUSTMENT_UNDEFINED constant in their Configuration class, consider wrapping the field access in a try-catch block for NoSuchFieldError. This ensures that if the field or constant is missing at runtime on such devices, the app will fail gracefully (treating bold text as unavailable) instead of crashing.

    static boolean isBoldText(Configuration configuration) {
      try {
        int fontWeightAdjustment = configuration.fontWeightAdjustment;
        return fontWeightAdjustment != Configuration.FONT_WEIGHT_ADJUSTMENT_UNDEFINED
            && fontWeightAdjustment >= BOLD_TEXT_WEIGHT_ADJUSTMENT;
      } catch (NoSuchFieldError e) {
        return false;
      }
    }

@Joyatou

Joyatou commented Jul 21, 2026

Copy link
Copy Markdown
Author

@camsim99 Thanks for the guidance — cherry-pick PR is up per the process doc. Could someone from the release team apply the cp: review label when convenient? CLA sign-in is pending on my side and I'll complete it shortly.

@Joyatou

Joyatou commented Jul 21, 2026

Copy link
Copy Markdown
Author

@googlebot I signed it!

…tter#184630)

## Summary
- Some vendor-modified Android runtimes report `SDK_INT >= 31` but ship
a `Configuration` class without the `fontWeightAdjustment` field (added
in API 31), causing a `NoSuchFieldError` crash at app startup in
`AccessibilityBridge.setBoldTextFlag`
- Wrap the `fontWeightAdjustment` access in a try/catch for
`NoSuchFieldError`, gracefully defaulting to non-bold text instead of
crashing

## Changes
-
`engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java`:
Added try/catch around `fontWeightAdjustment` field access with fallback
to `shouldBold = false`

Fixes flutter#184286

---------

Co-authored-by: Meylis <[email protected]>
Co-authored-by: jesswrd <[email protected]>
Co-authored-by: Matt Boetger <[email protected]>
Co-authored-by: Camille Simon <[email protected]>
(cherry picked from commit 8ad7de9)
@Joyatou
Joyatou force-pushed the cp/184630-fix-accessibility-bridge branch from 28a95d8 to 15c5a92 Compare July 21, 2026 16:20
@camsim99 camsim99 added the cp: review Cherry-picks in the review queue label Jul 21, 2026
@camsim99 camsim99 added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 21, 2026
@camsim99

Copy link
Copy Markdown
Contributor

@Joyatou thank you for taking the initiative to get this fix into stable and following the process as requested! :)

@mboetger mboetger added the CICD Run CI/CD label Jul 21, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 21, 2026
@auto-submit

auto-submit Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/189759, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label.

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Jul 21, 2026
@camsim99 camsim99 added the CICD Run CI/CD label Jul 21, 2026
@camsim99

camsim99 commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

@vashworth I just merged e63099ba54092411f44b4c62cf2341147ea3abcc into stable and I'm seeing failures on CICD here, so wondering if they're related. Do you mind taking a look? A snippet of the failures:

FAILED: FlutterMacOS.framework/Versions/A/Resources/Info.plist 
vpython3 ../../../flutter/build/copy_info_plist.py --source /Volumes/Work/s/w/ir/cache/builder/engine/src/flutter/shell/platform/darwin/macos/framework/Info.plist --destination /Volumes/Work/s/w/ir/cache/builder/engine/src/out/ci/host_release_framework/FlutterMacOS.framework/Versions/A/Resources/Info.plist --buildmode release
Traceback (most recent call last):
  File "../../../flutter/build/copy_info_plist.py", line 68, in <module>
    main()
  File "../../../flutter/build/copy_info_plist.py", line 55, in main
    clang_version = get_clang_version()
  File "../../../flutter/build/copy_info_plist.py", line 30, in get_clang_version
    version = subprocess.check_output([clang_executable, '--version'])
  File "/Users/chrome-bot/Library/Caches/vpython-root.502/store/cpython+kal0ha7mc3ifkjqc0l21dgvk38/contents/lib/python3.8/subprocess.py", line 415, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/Users/chrome-bot/Library/Caches/vpython-root.502/store/cpython+kal0ha7mc3ifkjqc0l21dgvk38/contents/lib/python3.8/subprocess.py", line 493, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Users/chrome-bot/Library/Caches/vpython-root.502/store/cpython+kal0ha7mc3ifkjqc0l21dgvk38/contents/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/chrome-bot/Library/Caches/vpython-root.502/store/cpython+kal0ha7mc3ifkjqc0l21dgvk38/contents/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 86] Bad CPU type in executable: '/Volumes/Work/s/w/ir/cache/builder/engine/src/flutter/build/../../flutter/buildtools/mac-x64/clang/bin/clang++'

Edit: Updates in #189865

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Jul 22, 2026
@camsim99 camsim99 added the CICD Run CI/CD label Jul 22, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Jul 23, 2026
@camsim99 camsim99 added autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD labels Jul 23, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 23, 2026
@auto-submit

auto-submit Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/189759, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label.

@camsim99 camsim99 added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 23, 2026
@auto-submit
auto-submit Bot merged commit 0cd6107 into flutter:flutter-3.44-candidate.0 Jul 23, 2026
9 checks passed
Anas-Qasem pushed a commit to Anas-Qasem/flutter that referenced this pull request Aug 11, 2026
…roid (flutter#189759)

Cherry-picks flutter#184630 (fixes flutter#184286) to `flutter-3.44-candidate.0`.

## Impacted Users
Devices on vendor-modified Android 11 ROMs that report `SDK_INT >= 31` but ship a `Configuration` class without the API-31 `fontWeightAdjustment` field. Confirmed in production on OnePlus 8 Pro (Android 11); the OnePlus/Oppo/Realme ROM family is the likely blast radius. flutter#184286 cited 95 fatal events, 100% OnePlus 8 Pro / Android 11.

## Impact Description
Hard crash at startup. `NoSuchFieldError` is thrown from `AccessibilityBridge.setBoldTextFlag` inside the `AccessibilityBridge` constructor during `FlutterActivity.onCreate`, so the process dies before any Dart runs — the app never opens on affected devices.

## Workaround
None from app code. The field read happens inside the engine's `AccessibilityBridge` constructor before the Dart isolate starts, so the embedding app cannot guard or catch it.

## Risk
Low. +20/-4 in a single file (`AccessibilityBridge.java`): moves the `fontWeightAdjustment` read into an `@RequiresApi(31)` `Api31Impl` inner class so ART's class verifier no longer eagerly resolves the field at class-load time on older or vendor-modified runtimes. Mirrors the hardening AndroidX Compose applied for the same crash (AOSP b/353988277). Only touches the already-failing path.

## Test Coverage
No automated test — the trigger is a device/ROM-specific `NoSuchFieldError` that isn't reproducible in CI. The change is defensive and validated against the production crash signature in flutter#184286.

## Validation Steps
Launch the app on an affected device (OnePlus 8 Pro / Android 11). Before: immediate startup crash. After: app launches normally; bold-text accessibility is simply treated as unavailable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD cp: review Cherry-picks in the review queue engine flutter/engine related. See also e: labels. platform-android Android applications specifically team-android Owned by Android platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants