New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 853247 link

Starred by 3 users

Issue metadata

Status: Started
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Task



Sign in to add a comment

Prefer tools:ignore="ContentDescription" to android:contentDescription="@null"

Project Member Reported by bsazonov@chromium.org, Jun 15 2018

Issue description

In many Chrome files, XML files have android:contentDescription="@null" attribute on ImageView/ImageButton tags. These were probably added to silence Lint warnings about ("Missing `contentDescription` attribute on image: ContentDescription [warning]").

These android:contentDescription="@null" attributes don't change behavior of ImageViews, as mContentDescription is already null by default for ImageView and ImageButton. However, these attributes do add some bytes to the APK size and they also need to be inflated.

There's a different way to explicitly silence this Lint error: by adding tools:ignore="ContentDescription". As far as I can tell from reading View and ImageView implementations, it gives the same behavior, but doesn't have extra costs in terms of binary size and CPU cycles during inflation.

There's one "but": https://developer.android.com/guide/topics/ui/accessibility/apps#label-elements recommends setting android:contentDescription="@null" on purely decorative ImageViews. However, I think for Chrome it makes sense to violate this recommendation and prefer tools:ignore="ContentDescription".

I've measured binary size effect and removing 102 android:contentDescription="@null" entries from Chrome XMLs has reduces the binary size by 2640 bytes.
 
SGTM
Project Member

Comment 2 by bugdroid1@chromium.org, Jun 25 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/eea187b7fa943f6986e928b331aa31343c6d53e1

commit eea187b7fa943f6986e928b331aa31343c6d53e1
Author: Boris Sazonov <bsazonov@chromium.org>
Date: Mon Jun 25 21:52:49 2018

[Android] Remove contentDescription="@null" attribute from XML layouts

This CL replaces android:contentDescription="@null" attributes on
ImageViews and ImageButtons with tools:ignore="ContentDescription".
As default content description for these views is already null, this
doesn't change the behavior, while reducing binary size and saving
cycles during inflation.

Bug: 853247
Change-Id: I1d20e477b1b3c27f897f49bdd95941e22ad2f543
Reviewed-on: https://chromium-review.googlesource.com/1102684
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570193}
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/accessibility_tab_switcher_list_item.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/account_chooser_dialog_item.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/account_management_account_row.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/account_picker_row.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/account_signin_account_view.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/account_signin_view.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/add_to_homescreen_dialog.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/autofill_card_unmask_prompt.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/bookmark_widget_item.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/bottom_sheet.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/bottom_toolbar.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/confirm_important_sites_list_row.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/connection_info.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/content_suggestions_all_dismissed_card_modern.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/content_suggestions_card_modern.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/content_suggestions_card_modern_reversed.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/contextual_suggestions_card_modern.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/contextual_suggestions_toolbar.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/control_container.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/custom_tabs_bottombar_item.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/custom_tabs_control_container.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/custom_tabs_toolbar_button.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/expanded_cast_controller.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/explore_sites_category_tile_view.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/fre_data_reduction_proxy.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/fre_tosanduma.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/infobar_control_icon_with_description.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/infobar_control_spinner.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/infobar_control_toggle.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/item_chooser_dialog_row.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/lightweight_fre_tos.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/location_bar.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/location_bar_base.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/menu_button.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/new_tab_page_all_dismissed.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/new_tab_page_incognito.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/new_tab_page_incognito_md.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/new_tab_page_snippets_card_large_thumbnail.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/new_tab_page_tile_grid_placeholder.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/offline_download_header.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/page_info_permission_row.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/password_generation_popup_suggestion.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/payment_option_edit_icon.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/payment_request_bottom_bar.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/payments_request_editor_textview.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/personalized_signin_promo_view_header.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/photo_picker_bitmap_view.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/preference_category.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/promo_dialog_layout.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/recent_tabs_group_item.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/recent_tabs_list_item.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/sad_tab.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/search_activity.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/share_dialog_item.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/signin_view.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/snackbar.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/tabular_context_menu_page.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/tabular_context_menu_row.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/text_message_with_link_and_icon_preference.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/textbubble_text_with_image.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/tile_view_classic.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/tile_view_classic_condensed.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/tile_view_modern.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/tile_view_modern_condensed.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/toolbar_tablet.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/update_permissions_dialog.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/upgrade_activity.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/web_notification_big.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/web_notification_button.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/web_notification_icon_frame.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/web_notification_small_icon.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/webapp_splash_screen_large.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/webapp_splash_screen_no_icon.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/webapp_splash_screen_small.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/chrome/android/java/res/layout/website_features.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/content/shell/android/java/res/layout/shell_view.xml
[modify] https://crrev.com/eea187b7fa943f6986e928b331aa31343c6d53e1/ui/android/java/res/layout/dropdown_item.xml

Comment 3 by wychen@chromium.org, Jun 26 2018

Does it make sense to add a presubmit checking to prevent future addition of android:contentDescription="@null"? Reviewers might not always be able to remember this and point it out.

Sign in to add a comment