Closed carloshwa closed 6 years ago
Is this issue unique to Amazon devices, or also reproduced in Nexus Player?
I think when the app goes to background, it may loose its surface. This information needs to be passed to Exo via by setting a NULL surface to Exo in onSurfaceDestroyed callback of SurfaceHolder. Is that happening?
Thanks for the quick response. I don't have a Nexus Player to test with but my FireTV Stick 2nd gen does not have the issue.
The limitation with this is if we background our app, since ExoPlayer throws an error, we are unable to resume video when we return.
I haven't tried setting surface to null in onSurfaceDestroyed
yet but does it make sense to have this handled in the ExoPlayer fork as a workaround since it's not necessary on other devices?
Well, setting surface to null when onSurfaceDestroyed is not specific to our device. It must be done on all devices. I have limited understanding here, but when the app goes to background whether the surface (resource) gets destroyed or not depends on memory situation of the system. So maybe in some devices, the surface is not destroyed immediately - but will when the memory is needed by other apps.
So please handle the onSurfaceDestroyed in your app and pass null to exo (using blocking sendmessage). This is the right way to fix this issue.
Hi,
I tried setting the Exo surface to null, and also manually releasing the surface in onSurfaceDestroyed but neither worked. Instead, releasing Exoplayer in onPause
instead of onStop
made the error go away. But this creates some challenges because now we have to handle the lifecycle differently for this specific device (our code is shared across the mobile Android version of our app and our FireTV version). But this may be an issue to raise with the FireTV engineering team, it sounds like there's not much that can be done about this from within ExoPlayer since it's lifecycle-related.
Ok I'll take a look.
by the way, "manually releasing the surface in onSurfaceDestroyed" - what do you mean by that. the fact that you got onSurfaceDestroyed means that the surface is destroyed.
Here's what I added:
surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder holder) { }
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { }
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
player.setVideoSurfaceView(null);
holder.getSurface().release();
}
});
holder.getSurface().release(); -- this line is not required. You are getting this callback because the surface is destroyed. nothing needs to be done here.
Hi, Any update on this issue with my last suggestion?
I am also having this issue even with setting the SurfaceView to null in the surfaceDestroyed callback. This issue seems to not only affecting Gen. 3 Fire TVs, but also the Fire TV Cube.
I am seeing this using version 2.8.2
work in progress
fix uploaded.
Issue description
When backgrounding the ExoPlayer sample app while video is playing,
IllegalStateException
is thrown and the player is destroyed.Reproduction steps
Version of ExoPlayer being used
2.5.4 & 2.6.1
Device(s) and version(s) of Android being used
FireTV 3rd Gen, FireOS 6.2.1.2
A full bug report captured from the device
exoplayer_firetv_log.txt