Repository navigation
[stable] Fix AccessibilityBridge startup crash on vendor-modified Android - #189759
Conversation
|
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. |
|
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. |
There was a problem hiding this comment.
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.
| static boolean isBoldText(Configuration configuration) { | ||
| int fontWeightAdjustment = configuration.fontWeightAdjustment; | ||
| return fontWeightAdjustment != Configuration.FONT_WEIGHT_ADJUSTMENT_UNDEFINED | ||
| && fontWeightAdjustment >= BOLD_TEXT_WEIGHT_ADJUSTMENT; | ||
| } |
There was a problem hiding this comment.
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;
}
}|
@camsim99 Thanks for the guidance — cherry-pick PR is up per the process doc. Could someone from the release team apply the |
|
@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)
28a95d8 to
15c5a92
Compare
|
@Joyatou thank you for taking the initiative to get this fix into stable and following the process as requested! :) |
|
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. |
|
@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 |
|
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. |
0cd6107
into
flutter:flutter-3.44-candidate.0
…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.
Cherry-picks #184630 (fixes #184286) to
flutter-3.44-candidate.0.Impacted Users
Devices on vendor-modified Android 11 ROMs that report
SDK_INT >= 31but ship aConfigurationclass without the API-31fontWeightAdjustmentfield. 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.
NoSuchFieldErroris thrown fromAccessibilityBridge.setBoldTextFlaginside theAccessibilityBridgeconstructor duringFlutterActivity.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
AccessibilityBridgeconstructor 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 thefontWeightAdjustmentread into an@RequiresApi(31)Api31Implinner 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
NoSuchFieldErrorthat 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.