PIP flickering
- Dominant language
- Java
- Stars
- 21.9k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I'm implementing PIP feature following the android developer guide.
When animating I'm using a `SurfaceView` (I can't use a `TextureView` because I can't play HDR videos).
When I am in pip mode and i tap on the pip window in order to show the control player i notice a flickering: the SurfaceView has a strange behavior as shown below:


You can reproduce the same problem updating the Exoplayer demo project:
here you can find the `git diff`
```
diff --git a/demos/main/src/main/AndroidManifest.xml b/demos/main/src/main/AndroidManifest.xml
index 053665502..2c36edab7 100644
--- a/demos/main/src/main/AndroidManifest.xml
+++ b/demos/main/src/main/AndroidManifest.xml
@@ -65,6 +65,7 @@
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"
android:launchMode="singleTop"
android:label="@string/application_name"
+ android:supportsPictureInPicture="true"
android:theme="@style/PlayerTheme">
diff --git a/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java b/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
index 5fb342be4..1da9a3634 100644
--- a/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
+++ b/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
@@ -19,6 +19,7 @@ import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.os.Build;
import android.os.Bundle;
import android.util.Pair;
import android.view.KeyEvent;
@@ -105,6 +106,10 @@ public class PlayerActivity extends AppCompatActivity
setContentView();
debugRootView = findViewById(R.id.controls_root);
debugTextView = findViewById(R.id.debug_text_view);
+
+ debugRootView.setVisibility(View.GONE);
+ debugTextView.setVisibility(View.GONE);
+
selectTracksButton = findViewById(R.id.select_tracks_button);
selectTracksButton.setOnClickListener(this);
@@ -160,11 +165,8 @@ public class PlayerActivity extends AppCompatActivity
@Override
public void onPause() {
super.onPause();
- if (Util.SDK_INT <= 23) {
- if (playerView != null) {
- playerView.onPause();
- }
- releasePlayer();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ enterPictureInPictureMode();
}
}
```
Android version: all android versions that support pip feature (from Android 24)
Tested on many different devices (Samsung Galaxy S20+, Samsung Galaxy S9, Pixel 3, Nexus 6 ecc...)
Exoplayer version: 2.13.1
Contributor guide
Assessment
This issue has not been assessed yet.