androidx / androidx/media

After 1.5.0, Android 15 may experience screen flickering

Open
#2,059 13 comments 7 reactions 1 assignee View on GitHub

@tonihei is already working on this.

Since Jan 24, 2025.

bug: device specific
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

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

https://github.com/user-attachments/assets/d2885f48-3850-4f03-a72f-744b915daf1f

Bug Report
  • You will email the zip file produced by adb bugreport to android-media-github@google.com after filing this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.