Skip to content

After 1.5.0, Android 15 may experience screen flickering #2059

Open

Description

@CarGuo

Version

Media3 1.5.0

More version details

>= 1.5.0

Devices that reproduce the issue

Android 15 emulated device

Image

Devices that do not reproduce the issue

Android OS Version < 15

Reproducible in the demo app?

Yes

Reproduction steps

demos/main :

Delaying playerView.setPlayer(player); until video is successfully prepared, screen flickering

It works well in version 1.4.x , but after upgrading to 1.5.x, this scenario does not work properly on the Android 15 emulator

5000 milliseconds is only for the convenience of setting the surface scene after simulating video playback

Index: demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java b/demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java
--- a/demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java	(revision 76088cd6af7f263aba238b7a48d64bd4f060cb8b)
+++ b/demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java	(date 1737381685094)
@@ -19,6 +19,7 @@
 import android.content.pm.PackageManager;
 import android.os.Build;
 import android.os.Bundle;
+import android.os.Handler;
 import android.util.Pair;
 import android.view.KeyEvent;
 import android.view.View;
@@ -279,7 +280,7 @@
       player.addAnalyticsListener(new EventLogger());
       player.setAudioAttributes(AudioAttributes.DEFAULT, /* handleAudioFocus= */ true);
       player.setPlayWhenReady(startAutoPlay);
-      playerView.setPlayer(player);
+
       configurePlayerWithServerSideAdsLoader();
       debugViewHelper = new DebugTextViewHelper(player, debugTextView);
       debugViewHelper.start();
@@ -294,6 +295,12 @@
     if (repeatModeExtra != null) {
       player.setRepeatMode(IntentUtil.parseRepeatModeExtra(repeatModeExtra));
     }
+    new Handler().postDelayed(new Runnable() {
+      @Override
+      public void run() {
+        playerView.setPlayer(player);
+      }
+    }, 5000);
     updateButtonVisibility();
     return true;
   }

Expected result

Work normally like version 1.4.x

Actual result

On Android 15, 1.5.x version, the screen will flicker

Media

When the problem is triggered in the demo

2025-01-20.22.06.37.mov

Bug Report

Activity

  1. tonihei commented on Jan 24, 2025

    @tonihei
    Collaborator

    Is this only happening on the emulator? And if so, does it happen for all videos? I tried to use the same emulator, but don't see anything suspicious when playing one of the videos in the demo app.

  2. self-assigned this
    on Jan 24, 2025
  3. CarGuo commented on Jan 25, 2025

    @CarGuo
    Author

    Because I don't currently have a real Android 15 device, I only found this issue on the Android 15 emulator.

    The problem occurs in all videos, mainly related to the timing of starting playback and the surface settings,

    It can reproduce in demos/main, but some simple modifications are needed, such as modifying PlayerActivity. java:

    Index: demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    diff --git a/demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java b/demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java
    --- a/demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java	(revision 76088cd6af7f263aba238b7a48d64bd4f060cb8b)
    +++ b/demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java	(date 1737381685094)
    @@ -19,6 +19,7 @@
     import android.content.pm.PackageManager;
     import android.os.Build;
     import android.os.Bundle;
    +import android.os.Handler;
     import android.util.Pair;
     import android.view.KeyEvent;
     import android.view.View;
    @@ -279,7 +280,7 @@
           player.addAnalyticsListener(new EventLogger());
           player.setAudioAttributes(AudioAttributes.DEFAULT, /* handleAudioFocus= */ true);
           player.setPlayWhenReady(startAutoPlay);
    -      playerView.setPlayer(player);
    +
           configurePlayerWithServerSideAdsLoader();
           debugViewHelper = new DebugTextViewHelper(player, debugTextView);
           debugViewHelper.start();
    @@ -294,6 +295,12 @@
         if (repeatModeExtra != null) {
           player.setRepeatMode(IntentUtil.parseRepeatModeExtra(repeatModeExtra));
         }
    +    new Handler().postDelayed(new Runnable() {
    +      @Override
    +      public void run() {
    +        playerView.setPlayer(player);
    +      }
    +    }, 5000);
         updateButtonVisibility();
         return true;
       }

    It mainly occurs on Android 15. After the 1.5.0 version of the media player starts playing, set the surface to the player, such as playerView.setPlayer (player), then screen flickering
    
    The above code mainly simulates the scenario of setting surface after the media player starts playing, by delaying by 5000 milliseconds and then calling playerView.setPlayer (player)
    
    The scenario where the problem occurs is when we only set surface to the media player after it starts playing

    In Android 15, this issue does not occur in versions 1.4.0 and below .

    Comparison of videos in different scenarios

    Right:

    studio_video_1737784878273712.MOV

    Error:

    studio_video_1737784878273712.2.MOV
  4. tonihei commented on Jan 27, 2025

    @tonihei
    Collaborator

    Thanks, I can reproduce this as well now (didn't realize the delayed attachment of PlayerView is relevant).

    This looks like a clear emulator bug (playback works fine on a real device). I've reported it to the emulator team internally (ref b/392540687).

  5. NoNews commented on Mar 11, 2025

    @NoNews
    Contributor

    Observing very similar issue with flickering with 1.5.1:

    Investigation showed:

    • This issue also happens on a Xiaomi and OPPO devices
    • Only Android 15

    Question
    Can it be related to this commit?

  6. tonihei commented on Mar 12, 2025

    @tonihei
    Collaborator

    Can it be related to this commit?

    Sounds like it could be related given the setup steps with the delayed surface setting. If you can reproduce locally on the mentioned devices, could you try overriding MediaCodecVideoRenderer.shouldUseDetachedSurface and return false from the method? You can inject this customized renderer in the DefaultRenderersFactory passed to ExoPlayer.Builder.

  7. NoNews commented on Mar 12, 2025

    @NoNews
    Contributor

    Yes, I tried it yesterday and it looks like the reason, as I can no longer reproduce the issue. (I've now tested this on the mentioned emulator — without the fix, the issue appears consistently, and with the fix applied, the issue is resolved. However, I still need to verify these results on mentioned physical devices, it looks like decoders related).
    I'll let you know how it's going and if other vendors/manufacturers are affected.

    Thanks!

    Here is the code for reference — please let me know if you have any suggestions!

    class CustomRendersFactory(
      context: Context,
    ) : DefaultRenderersFactory(context) {
    
    
      override fun buildVideoRenderers(
        context: Context,
        extensionRendererMode: Int,
        mediaCodecSelector: MediaCodecSelector,
        enableDecoderFallback: Boolean,
        eventHandler: Handler,
        eventListener: VideoRendererEventListener,
        allowedVideoJoiningTimeMs: Long,
        out: ArrayList<Renderer>,
      ) {
        super.buildVideoRenderers(
          /* context = */ context,
          /* extensionRendererMode = */ extensionRendererMode,
          /* mediaCodecSelector = */ mediaCodecSelector,
          /* enableDecoderFallback = */ enableDecoderFallback,
          /* eventHandler = */ eventHandler,
          /* eventListener = */ eventListener,
          /* allowedVideoJoiningTimeMs = */ allowedVideoJoiningTimeMs,
          /* out = */ out,
        )
        runCatching {
          synchronized(this) {
            val index = out.indexOfFirst { it is MediaCodecVideoRenderer }
            if (index != -1) {
              out[index] = CustomMediaCodecVideoRenderer(
                /* context = */ context,
                /* mediaCodecSelector = */ mediaCodecSelector,
                /* allowedJoiningTimeMs = */ allowedVideoJoiningTimeMs,
                /* eventHandler = */ eventHandler,
                /* eventListener = */ eventListener,
                /* maxDroppedFramesToNotify = */ 50,
                internalFeatures = internalFeatures,
              )
            }
          }
        }
      }
    }
    
    class CustomMediaCodecVideoRenderer(
      context: Context,
      mediaCodecSelector: MediaCodecSelector,
      allowedJoiningTimeMs: Long,
      eventHandler: Handler,
      eventListener: VideoRendererEventListener,
      maxDroppedFramesToNotify: Int,
    ) : MediaCodecVideoRenderer(
      context,
      mediaCodecSelector,
      allowedJoiningTimeMs,
      eventHandler,
      eventListener,
      maxDroppedFramesToNotify,
    ) {
    
      override fun shouldUseDetachedSurface(codecInfo: MediaCodecInfo): Boolean {
        // I've returned `false` when I was testing it on emulator.
     
        if (Util.SDK_INT >= 35 && deviceExcludedFromDetachedSurface()) {
          return false
        }
        return super.shouldUseDetachedSurface(codecInfo)
      }
    
      private fun deviceExcludedFromDetachedSurface(): Boolean {
        return Build.MANUFACTURER in EXCLUDED_DEVICES_NAME
      }
    
      private companion object {
        val EXCLUDED_DEVICES_NAME = setOf(
          "Xiaomi",
          "OPPO",
        )
      }
    }
  8. tonihei commented on Mar 12, 2025

    @tonihei
    Collaborator

    Thanks for the confirmation! We probably need to add a similar exclusion mechanism as in your comment above. When you say it "looks like decoder related" - do you mean it only reproduces with specific decoders? If so, could you share which codec name is affected exactly on the physical devices? Ideally, it would be great if you share a bugreport from such a device as well so we can forward this to the codec team for further investigation (you can send it to android-media-github@google.com with "Issue #2059" in the subject)

  9. tonihei commented on Mar 18, 2025

    @tonihei
    Collaborator

    We'll exclude Xiaomi and OPPO devices from the new feature with the 1.6.0-rc02 release so that you don't need to add a manual workaround. If you do have more details on the involved codecs, we may be able to provide a more targeted workaround in the future.

    We also filed an internal bug with the codec team to investigate further (internal ref b/402701573) and see if there is a way to avoid this problematic behavior by additional platform tests.

  10. NoNews commented on Mar 20, 2025

    @NoNews
    Contributor

    @tonihei Great. Thank you so much. Sorry for late follow up from my end.

    Adding more details

    1. The workaround that we've introduced is working _(based on the user feedback we've received, _but we're still monitoring it & will let you know if it changes__)

    2. Unfortunately we don't report which decoders are used during playback yet, but I've queried a full list of affected devices:

    • Xiaomi 23053RN02Y
    • Xiaomi 23100RN82L
    • Xiaomi 23108RN04Y
    • Xiaomi Redmi Note 7
    • Xiaomi 2312DRAABG
    • Xiaomi 2310FPCA4G
    • Xiaomi 2311DRN14I
    • Xiaomi 2404ARN45A
    • Xiaomi 23053RN02L
    • OPPO CPH2531
    • Google Pixel 8 (only 1 report from this device. We were not able to repro this on real device)

    All Android 15.

    1. Problems look visually differently on the devices
    Xiaomi & Oppo Pixel 8
    Xiaomi & Oppo Pixel 8

    Since the problems appear visually different, I suspected they may be decoder-related. Both (Dash & Mp4) playbacks were affected.
    There still may be a small chance though that these issues are different, but so far we haven't received a feedback that the workaround didn't work.

    Also, we fall back to software decoders when hardware decoding is unavailable.

    Thanks again, and please let me know if you need more details.

  11. NoNews commented on Apr 2, 2025

    @NoNews
    Contributor

    @tonihei hi, can confirm that we also noticed it on Realme RMX3771, maybe it also worth excluding.

    Thanks!

  12. alexsullivan-substack commented on May 16, 2025

    @alexsullivan-substack

    Hey folks, I'm seeing the same issue on my emulator and trying to discern how concerned I should be about this out in the wild. It sounds like it is a real issue impacting a range of devices, is that correct? If so, is there any mitigation we can do?

    Edit: For reference I'm on version 1.6.0

  13. tonihei commented on May 23, 2025

    @tonihei
    Collaborator

    If so, is there any mitigation we can do?

    @alexsullivan-substack The devices we know are affected are already excluded from the feature.

    can confirm that we also noticed it on Realme RMX3771, maybe it also worth excluding

    I can add "realme" to the excluded list. They are part of the same company group as OPPO, so this is consistent at least.

    we don't report which decoders are used during playback

    I checked the available hardware decoders for H264 on all the mentioned devices and it looks like they all use c2.mtk.avc.decoder. However, there are many other devices also using this codec (including some very common ones from other manufacturers), so it can't really be just the codec itself that causes the issue.

    internal ref b/402701573

    There are no news on the internal investigation by the codec team yet to understand where this may be coming from.

  14. NoNews commented on May 27, 2025

    @NoNews
    Contributor

    Hi @tonihei, we're seeing this issue with more vendors pushing updates to Android 15 — which has been confirmed by users.

    Here is our current list of excluded devices :
    "xiaomi",
    "oppo",
    "motorola",
    "realme",
    "lenovo"

    Opened a PR that expands the device list from this improvement. I understand it may be temporary until internal ref b/402701573 is resolved.

  15. added a commit that references this issue on Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions