question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Always throws the exception when setting the Surface that has already been released

See original GitHub issue
2021-07-31 23:30:25.130 4113-8278/com.ivuu E/VideoFrameReleaseHelper: Failed to call Surface.setFrameRate
      java.lang.IllegalStateException: Surface has already been released.
        at android.view.Surface.checkNotReleasedLocked(Surface.java:696)
        at android.view.Surface.setFrameRate(Surface.java:905)
        at com.google.android.exoplayer2.video.VideoFrameReleaseHelper.setSurfaceFrameRateV30(VideoFrameReleaseHelper.java:389)
        at com.google.android.exoplayer2.video.VideoFrameReleaseHelper.clearSurfaceFrameRate(VideoFrameReleaseHelper.java:379)
        at com.google.android.exoplayer2.video.VideoFrameReleaseHelper.onSurfaceChanged(VideoFrameReleaseHelper.java:182)
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.setSurface(MediaCodecVideoRenderer.java:549)
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.handleMessage(MediaCodecVideoRenderer.java:507)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.deliverMessage(ExoPlayerImplInternal.java:1503)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.sendMessageToTarget(ExoPlayerImplInternal.java:1467)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.sendMessageInternal(ExoPlayerImplInternal.java:1442)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:509)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:246)
        at android.os.HandlerThread.run(HandlerThread.java:67)

It would be great if check the surface.isValid() before the surface.setFrameRate(frameRate, compatibility);

@RequiresApi(30)
private static void setSurfaceFrameRateV30(Surface surface, float frameRate) {
  int compatibility =
      frameRate == 0
          ? Surface.FRAME_RATE_COMPATIBILITY_DEFAULT
          : Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE;
  try {
    surface.setFrameRate(frameRate, compatibility);
  } catch (IllegalStateException e) {
    Log.e(TAG, "Failed to call Surface.setFrameRate", e);
  }
}

ExoPlayer: 2.13.3 Android: 11

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ojw28commented, Aug 1, 2021

I doubt you need to manually release a Surface when surfaceDestroyed is called. That said, if you really want to do this for some reason, why don’t you swap the order of the calls so that you clear the surface from the player first? You shouldn’t ever leave the player with an invalid surface, however temporarily, which is what you appear to be doing here.

0reactions
google-oss-botcommented, Aug 30, 2021

Since there haven’t been any recent updates here, I am going to close this issue.

@ShawnLin013 if you’re still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Do I have to break after throwing exception? - Stack Overflow
(3) Does a throw always quit the method? NO. If the throw is in a try and the try has a matching catch...
Read more >
Understanding Exceptions while debugging with Visual Studio
In Visual Studio, when exceptions are thrown or end up unhandled, the debugger can help you debug these by breaking just like it...
Read more >
Java How To Program (late objects) 10e, Ch 11 - Quizlet
True or False: When an exception is thrown by code inside a try block, all of the statements in the try block are...
Read more >
Chapter 13 Exception Handling - SMU
Objective: This example demonstrates declaring, throwing, and catching exceptions by modifying the setRadius method in the Circle class defined in Chapter 8.
Read more >
Top 15 C++ Exception handling mistakes and how to avoid ...
When an exception is thrown and control passes from a try block to a handler, the C++ run time calls destructors for all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found