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

Can not catch all ExoPlayer errors leading to app crash #2592

Closed
MichalStranik opened this issue Mar 22, 2017 · 8 comments
Closed

Can not catch all ExoPlayer errors leading to app crash #2592

MichalStranik opened this issue Mar 22, 2017 · 8 comments

Comments

@MichalStranik
Copy link

Hello,

I described problem here.

Problem is that application crash on some (not all, some of them I can catch) random errors mainly with DRM, but I am not able to catch them with set listener. Even after I set listener, app still sometime crash, if there is bigger error.

Last crash I could observe, was this:
Caused by: com.google.android.exoplayer2.drm.DrmSession$DrmSessionException: com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to https://...

Please help me to catch all errors to avoid app crashing.

Thank you.

@ojw28 ojw28 added the bug label Mar 22, 2017
@ojw28
Copy link
Contributor

ojw28 commented Mar 22, 2017

Yes, there are a few cases where we don't correctly handle and propagate internal errors (which we don't expect to occur, but we should make sure to never cause process death).

@MichalStranik
Copy link
Author

Ok, but what next? Can I do something? Or is there any time frame when this will be fixed?

@ojw28
Copy link
Contributor

ojw28 commented Mar 23, 2017

I'm actually quite confused by your post of stack overflow. There's no evidence there that the stack trace you've posted there actually caused your app to crash. It looks like it would have been caught and propagated to onPlayerError as expected. Please can you provide a proper bug report, or at least complete logcat showing the app crashing. If your app is actually crashing then I think you'd expect a corresponding logs to begin with FATAL EXCEPTION. Something like:

AndroidRuntime: FATAL EXCEPTION: threadname
AndroidRuntime: Process: your.package.name.here, PID: 1234

@MichalStranik
Copy link
Author

MichalStranik commented Mar 24, 2017

Ok, I added there full error message.

@ojw28
Copy link
Contributor

ojw28 commented Mar 24, 2017

Your app is crashing due to your own code:

E/AndroidRuntime: FATAL EXCEPTION: main   
Process: com.mypackage.name, PID: 17960   
java.lang.IllegalStateException   
    at com.google.android.exoplayer2.util.Assertions.checkState(Assertions.java:79)   
    at com.google.android.exoplayer2.ExoPlaybackException.getSourceException(ExoPlaybackException.java:111)   
    at com.mypackage.name.ui.activities.PlayerActivity$1.onPlayerError(PlayerActivity.java:260)

Our Javadoc indicates that getSourceException throws IllegalStateException if type != TYPE_SOURCE, so you need to check the type before you make that call.

@ojw28 ojw28 closed this as completed Mar 24, 2017
@MichalStranik
Copy link
Author

MichalStranik commented Mar 24, 2017

I see, so when I handle error by this, it should be ok, right?

       @Override
        public void onPlayerError(ExoPlaybackException error) {
            switch (error.type) {
                case ExoPlaybackException.TYPE_SOURCE:
                    Log.e(TAG, "TYPE_SOURCE: " + error.getSourceException().getMessage());
                    break;

                case ExoPlaybackException.TYPE_RENDERER:
                    Log.e(TAG, "TYPE_RENDERER: " + error.getRendererException().getMessage());
                    break;

                case ExoPlaybackException.TYPE_UNEXPECTED:
                    Log.e(TAG, "TYPE_UNEXPECTED: " + error.getUnexpectedException().getMessage());
                    break;
            }
    });

@ojw28
Copy link
Contributor

ojw28 commented Mar 24, 2017

Yes. Although if you don't care what type the cause is, you can just do this:

@Override
public void onPlayerError(ExoPlaybackException error) {
    Log.e(TAG, error.getCause().getMessage());
}

@MichalStranik
Copy link
Author

Thank you.

@google google locked and limited conversation to collaborators Aug 3, 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

2 participants