Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After 1.5.0, Android 15 may experience screen flickering #2059

Open
1 task done
CarGuo opened this issue Jan 20, 2025 · 3 comments
Open
1 task done

After 1.5.0, Android 15 may experience screen flickering #2059

CarGuo opened this issue Jan 20, 2025 · 3 comments
Assignees

Comments

@CarGuo
Copy link

CarGuo commented Jan 20, 2025

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

  • You will email the zip file produced by adb bugreport to [email protected] after filing this issue.
@tonihei
Copy link
Collaborator

tonihei commented Jan 24, 2025

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.

@tonihei tonihei self-assigned this Jan 24, 2025
@CarGuo
Copy link
Author

CarGuo commented Jan 25, 2025

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

@tonihei
Copy link
Collaborator

tonihei commented Jan 27, 2025

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).

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

No branches or pull requests

3 participants