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

Black screen when recreating SurfaceView #1599

Closed
sergiomartinez4 opened this issue Jun 15, 2016 · 4 comments
Closed

Black screen when recreating SurfaceView #1599

sergiomartinez4 opened this issue Jun 15, 2016 · 4 comments

Comments

@sergiomartinez4
Copy link

sergiomartinez4 commented Jun 15, 2016

I've seen this issue already reported a few times, specially this one #1084, but all of them involve using TextureView, which is not an option for us.

The way to reproduce it is similar as the other issues reported, by destroying and recreating the SurfaceView. where once the method player.setPlayWhenReady(true) is called, the Audio starts playing, but the onDrawnToSurface(surface) takes around 3 seconds to be called.

I added this code on the OnCreate of the PlayerActivity on the demo app from ExoPlayer.

@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
final Handler handler = new Handler(this.getMainLooper());
    handler.postDelayed(new Runnable() {
      @Override
      public void run() {
        Log.w(TAG, "RUNNING FIRST POST");
        if (player != null) {
          player.removeListener(PlayerActivity.this);
          player.setPlayWhenReady(false);

        }
        surfaceView.setVisibility(View.GONE);

        handler.postDelayed(new Runnable() {
          @Override
          public void run() {
            Log.w(TAG, "RUNNING SECOND POST");
            surfaceView.setVisibility(View.VISIBLE);
            if (player != null) {
              player.addListener(PlayerActivity.this);
              player.setPlayWhenReady(true);
            }
          }
        }, 5000);
      }
    }, 6000);

It's more noticeable when playing the BipBop video: https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8

After adding that code and installing the app, play the video. After 6 seconds the video will stop for 5 seconds. After resuming, the audio will start playing, and the video will play around 3 seconds later.

I tested it on a Nexus 5 5.1, and a HTC One 5.1.

Is there an optimized way to get around that?

@Ood-Tsen
Copy link
Contributor

I test it on branch 'dev-2.X.X-experimental' on HTC One Android 5.1.

Video and audio come almost at the same time (closed , only slightly delayed).
But my problem is the picture is broken at very beginning. It should not be sync frame at that time.

@sergiomartinez4
Copy link
Author

sergiomartinez4 commented Jun 22, 2016

thanks for the info @Ood-Tsen , I just tried it and the delayed is definitely reduced, but I'm also getting the trash pixels at the beginning

@ghost
Copy link

ghost commented Feb 22, 2017

@Ood-Tsen i get the same problem. does u fixed it?

@ojw28
Copy link
Contributor

ojw28 commented Jun 24, 2017

Smoothly switching between surfaces (including detaching and re-attaching) is tracked by #677.

@ojw28 ojw28 closed this as completed Jun 24, 2017
@google google locked and limited conversation to collaborators Oct 23, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants