Skip to content

Finalize pruning of services/device peripheral modules#10778

Open
johnxwork wants to merge 1 commit into
youtube:mainfrom
johnxwork:pr-prune-services-device
Open

Finalize pruning of services/device peripheral modules#10778
johnxwork wants to merge 1 commit into
youtube:mainfrom
johnxwork:pr-prune-services-device

Conversation

@johnxwork
Copy link
Copy Markdown
Contributor

This change completes the pruning of unused peripheral hardware modules (WebUSB, Web Bluetooth, WebHID, Web Serial, and Web NFC) in content/browser and services/device. Gated StoragePartition maps and browser binders under !BUILDFLAG(IS_COBALT).

This additional pruning achieves the following binary size savings on Android:

  • libchrobalt.so: -237,568 bytes (-232.0 KB)
  • Cobalt.apk: -261,708 bytes (-255.5 KB)

This change completes the pruning of unused peripheral hardware modules
(WebUSB, Web Bluetooth, WebHID, Web Serial, and Web NFC) in content/browser
and services/device. Gated StoragePartition maps and browser binders
under !BUILDFLAG(IS_COBALT).

This additional pruning achieves the following binary size savings on Android:
- libchrobalt.so: -237,568 bytes (-232.0 KB)
- Cobalt.apk: -261,708 bytes (-255.5 KB)
@johnxwork johnxwork requested a review from a team as a code owner June 5, 2026 00:30
@johnxwork johnxwork requested a review from oxve June 5, 2026 00:30
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

🤖 Gemini Suggested Commit Message


cobalt: Finalize pruning of peripheral modules

Complete the pruning of unused peripheral hardware modules, including
WebUSB, Web Bluetooth, WebHID, Web Serial, and Web NFC, from the
content and services layers. This change gates browser interface
binders, StoragePartition maps, and device service dependencies
behind the IS_COBALT build flag.

The removal of these modules provides significant binary size
reductions, specifically saving approximately 232 KB in the Android
shared library and 255 KB in the Cobalt APK.

Bug: 10778

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message

Copy link
Copy Markdown
Contributor

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

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 introduces build-time exclusions and conditional preprocessor blocks under the is_cobalt flag to disable several web APIs and services (such as Bluetooth, USB, HID, NFC, and Serial) on the Cobalt platform. The review feedback highlights a critical issue in services/device/BUILD.gn where the accidental removal of the IS_SERIAL_ENABLED_PLATFORM definition disables the Serial service globally across all platforms. Additionally, the feedback advises replacing deprecated streaming usage of NOTREACHED() with the standard non-streaming NOTREACHED(); macro to prevent compilation failures in newer milestones.

Comment thread services/device/BUILD.gn
Comment on lines 89 to +91
if (is_serial_enabled_platform) {
deps += [ "//services/device/serial" ]
defines = [ "IS_SERIAL_ENABLED_PLATFORM" ]
}
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.

high

Removing defines = [ "IS_SERIAL_ENABLED_PLATFORM" ] will prevent IS_SERIAL_ENABLED_PLATFORM from being defined during compilation. This will disable the Serial service on all platforms (including non-Cobalt platforms like Windows, Mac, Linux, and Android) because the C++ code (e.g., in device_service.cc) relies on this macro to include and bind the serial port manager. Please restore the defines statement inside the is_serial_enabled_platform block.

Suggested change
if (is_serial_enabled_platform) {
deps += [ "//services/device/serial" ]
defines = [ "IS_SERIAL_ENABLED_PLATFORM" ]
}
if (is_serial_enabled_platform) {
deps += [ "//services/device/serial" ]
defines = [ "IS_SERIAL_ENABLED_PLATFORM" ]
}


usb_device_manager_->AddReceiver(std::move(receiver));
#else
NOTREACHED() << "WebUSB is not supported on Cobalt.";
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

In modern Chromium (and thus Cobalt), NOTREACHED() has been updated to be a non-streaming macro (or behaves as [[noreturn]] depending on the build configuration). Using the operator<< stream syntax with NOTREACHED() is deprecated and will cause compilation errors in newer milestones. Please use NOTREACHED(); without any stream arguments.

Suggested change
NOTREACHED() << "WebUSB is not supported on Cobalt.";
NOTREACHED();


usb_device_manager_test_->BindReceiver(std::move(receiver));
#else
NOTREACHED() << "WebUSB is not supported on Cobalt.";
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

In modern Chromium (and thus Cobalt), NOTREACHED() has been updated to be a non-streaming macro (or behaves as [[noreturn]] depending on the build configuration). Using the operator<< stream syntax with NOTREACHED() is deprecated and will cause compilation errors in newer milestones. Please use NOTREACHED(); without any stream arguments.

Suggested change
NOTREACHED() << "WebUSB is not supported on Cobalt.";
NOTREACHED();

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant