Badoo Ivan Dyatlov Jun 16, 2020

WebRTC on Android: Enabling Hardware Encoding Across Devices

Article Summary

Ivan Dyatlov from Bumble Tech discovered that WebRTC's H.264 hardware encoding failed on most Android 5.x devices despite official support claims. His deep dive into codec implementations reveals why video calls drain batteries on millions of smartphones.

Bumble and Badoo needed reliable video calling across all Android devices, especially older models from 2014-2016 still widely used. The team expected H.264 hardware encoding to work seamlessly on Android 5.0+, but reality proved far messier. This article documents their journey through manufacturer-specific codec quirks and the fixes that enabled hardware encoding across diverse chipsets.

Key Takeaways

Critical Insight

Enabling H.264 hardware encoding across Android devices requires manufacturer-specific workarounds for color formats, bitrate modes, and resolution handling that standard WebRTC implementations miss.

The article includes a detailed breakdown of which codec prefixes need specific fixes and the surprising forum post that solved a six-year-old encoding problem.

About This Article

Problem

Ivan Dyatlov's team noticed that Android's Compatibility Test Suite video encoding tests ballooned from 160 lines of code in Android 4.3 to 740 in Android 10. Google didn't start serious codec compliance testing until version 5.0, which meant manufacturers ended up with inconsistent implementations across devices.

Solution

Badoo changed WebRTC's approach from an allowlist that only supported Qualcomm and Exynos chipsets to a blocklist targeting software codec prefixes like OMX.google and OMX.SEC. This let them detect hardware encoding on Spreadtrum, MediaTek, HUAWEI, and MARVELL chipsets that the old system missed.

Impact

The fixes enabled hardware encoding on most devices running Android 5.0 and 5.1. Analysis showed that the majority of users had Spreadtrum, MediaTek, HUAWEI, or MARVELL chipsets that had been falling back to software encoding. This reduced CPU load and battery drain on millions of older smartphones.