google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.71k stars 6.02k forks source link

Video squashed while SurfaceView rotation animation on Android N+ devices #3022

Closed StevenRudenko closed 6 years ago

StevenRudenko commented 7 years ago

Issue description

According to documentation:

SurfaceView should therefore be preferred over TextureView where possible. TextureView should be used only if SurfaceView does not meet your needs. One example is where smooth animations or scrolling of the video surface is required prior to Android N (see How do I get smooth animation/scrolling of video?). For this case, it’s preferable to use TextureView only when SDK_INT is less than 24 (Android N) and SurfaceView otherwise.

However while using SurfaceView on Android N+ devices video playback is squashed while view rotation animation.

Reproduction steps

  1. Add SurfaceView inside AspectRatioFrameLayout and set it as source for player: SimpleExoPlayer.setVideoSurface(surface)
  2. Apply rotation animation to AspectRatioFrameLayout:
    Animation anim = AnimationUtils.loadAnimation(this, R.anim.demo_animation);
    ratioFrameLayout.startAnimation(anim);

res/anim/demo_animation.xml:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">
    <scale
        android:duration="1500"
        android:fillAfter="true"
        android:fromXScale="1."
        android:fromYScale="1."
        android:interpolator="@android:anim/accelerate_decelerate_interpolator"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale=".5"
        android:toYScale=".5" />

    <rotate
        android:fillAfter="true"
        android:repeatCount="infinite"
        android:interpolator="@android:anim/accelerate_decelerate_interpolator"
        android:repeatMode="restart"
        android:startOffset="1500"
        android:duration="3000"
        android:fromDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="360" />

</set>
  1. Observe video playback while view animation.

AC: Video playback correctly renders inside SurfaceView ER: Video squashed while view rotation. See screen recorded: https://drive.google.com/a/ua.glomex.com/file/d/0BzW7GFOq6PIGaXNtOUZmM3d4cGM/view?usp=sharing

Please note that if TextureView is used instead of SurfaceView, everything renders correctly on all devices.

Is there preferred way to fix this issue or SurfaceView is not good option for view animation on all Android versions (N+ too)?

Link to test content

Version of ExoPlayer being used

r2.3.1

Device(s) and version(s) of Android being used

All Android N+ devices

A full bug report captured from the device

tonihei commented 6 years ago

Closing due to inactivity.