Always throws the exception when setting the Surface that has already been released
See original GitHub issue2021-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:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I doubt you need to manually release a
Surface
whensurfaceDestroyed
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.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.