From 06c0f5549e366071ad98050e85ed0e8f1cd36fdf Mon Sep 17 00:00:00 2001 From: tonihei Date: Tue, 18 Mar 2025 08:35:56 -0700 Subject: [PATCH] Exclude Xiaomi and OPPO devices from detached surface mode Ideally, we'd find a more targeted exclusion as it may depend on specific codecs. The current workaround should help with the reported issues that are limited to Xiaomi and OPPO. Issue: androidx/media#2059 #cherrypick PiperOrigin-RevId: 738017969 --- RELEASENOTES.md | 3 +++ .../media3/exoplayer/mediacodec/MediaCodecInfo.java | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index ba6178e21c..15e30baabb 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -92,6 +92,9 @@ This release includes the following changes since * Fix issue where a player without a surface was ready immediately and very slow decoding any pending frames ([#1973](https://github.com/androidx/media/issues/1973)). + * Exclude Xiaomi and OPPO devices from detached surface mode to avoid + screen flickering + ([#2059](https://github.com/androidx/media/issues/2059)). * Session: * Fix bug where a stale notification stays visible when the playlist is cleared ([#2211](https://github.com/androidx/media/issues/2211)). diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecInfo.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecInfo.java index 08ef1d5be6..6dfda94780 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecInfo.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecInfo.java @@ -711,7 +711,8 @@ public final class MediaCodecInfo { private static boolean isDetachedSurfaceSupported(@Nullable CodecCapabilities capabilities) { return Util.SDK_INT >= 35 && capabilities != null - && capabilities.isFeatureSupported(CodecCapabilities.FEATURE_DetachedSurface); + && capabilities.isFeatureSupported(CodecCapabilities.FEATURE_DetachedSurface) + && !needsDetachedSurfaceUnsupportedWorkaround(); } private static boolean areSizeAndRateSupported( @@ -855,8 +856,8 @@ public final class MediaCodecInfo { } /** - * Whether a profile is excluded from the list of supported profiles. This may happen when a - * device declares support for a profile it doesn't actually support. + * Returns whether a profile is excluded from the list of supported profiles. This may happen when + * a device declares support for a profile it doesn't actually support. */ private static boolean needsProfileExcludedWorkaround(String mimeType, int profile) { // See https://github.com/google/ExoPlayer/issues/3537 @@ -864,4 +865,9 @@ public final class MediaCodecInfo { && CodecProfileLevel.HEVCProfileMain10 == profile && ("sailfish".equals(Build.DEVICE) || "marlin".equals(Build.DEVICE)); } + + /** Returns whether the device is known to have issues with the detached surface mode. */ + private static boolean needsDetachedSurfaceUnsupportedWorkaround() { + return Build.MANUFACTURER.equals("Xiaomi") || Build.MANUFACTURER.equals("OPPO"); + } }