Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Android SDK - Pausing the activity when the player is not loaded causes the application to crash


Hello,

I post this bug report here since I couldn't find any GitHub repository for the Android SDK to post an issue on.

When the media is not loaded and I try to pause (by going back for instance) an activity which contains a JWPlayerFragment, the application crashes.

Here is the crash stack trace, you can see that it exclusively comes from the JWPlayer player and not my activity : https://pastebin.com/NCingY8V

Am I doing something wrong, or is it really an internal JWPlayer bug ?

Thanks !

22 Community Answers

George

JW Player Support Agent  
0 rated :

Hi,

For me to reproduce this issue reliably I will need this information about your application:

Device’s Android Version:
JW Player SDK for Android version number:
Device make and model where you are experiencing this issue:
Provide step by step instructions on how to reproduce your issue:
JW Player Demo Application Source Code that is also experiencing the issue:

As the last field suggests, please replicate this issue using the JW Player Demo Application and send us a link to a zipped version of the entire Android Studio Project for testing which can be found here:
https://github.com/jwplayer/jwplayer-sdk-android-demo

Sincerely,
George
JW Player
Android Support Engineer

n...

User  
0 rated :

Hi,

Thanks for your reply ! Here is what you demanded :

Device's Android Version : this crash occured on two devices running Android 6 and a Nexus 5X running Android 7.1.2
JW Player SDK for Android version number : supposedly the latest, 2.7.0+15
Device make and model where you are experiencing this issue : LGE Nexus 5X, Samsung SM-T580 and Kapsys SmartVision 2 (french phone for visually impaired people)

Step by step instructions to reproduce this issue :

1. Download the sample code ZIP below
2. Load it in the most recent version of Android Studio and make it run on your device ; the JWPlayer dependency is loaded from Maven using Gradle, no additionnal step should be required
3. Open the app in your device and quickly press the back button as soon as the activity is loaded, before the video starts ; it could take multiple attempts to achieve
4. The app will close (since there is only one activity) but will crash, here are the logs I got from it : https://pastebin.com/856aBUwG

It's worth noting that I use a JWPlayerFragment instead of the JWPlayerView directly. I load a live stream from my company's web service and play it immediately in the onCreate method. Background audio is also enabled, which may be the root cause of the crash.

The crash may be because I try to pause the fragment while the player is loading the stream, before playing it. The activity gets paused, in the meantime the loading finishes and the player tries to play the video, failing and crashing the app. That's just a supposition.

You can download the sample code here : https://up2sha.re/file?f=drrrpUlzsHhX&lang=us (use the download button in the top-right corner)

Thanks for your assistance :)

George

JW Player Support Agent  
0 rated :

Hi,

I’m testing with our latest SDK, 2.7.3 on a Nexus 6P running Android 7.1.2, I’m unable to reproduce the issue.

Sincerely,
George
JW Player
Android Support Engineer

n...

User  
0 rated :

Hi,

I made a video of the crash, you can watch it there : https://www.youtube.com/watch?v=5_s8Q75CrxA&feature=youtu.be

When you see the activity closing that's because I pressed the back button. It crashes right after, which is a problem if there are other activities in the stack.

George

JW Player Support Agent  
0 rated :

Can you reproduce the issue by calling finish() in the appropriate section of the source code and send that over?

n...

User  
0 rated :

Calling finish() in onBackPressed doesn't fix the issue, and I don't see where I could put it elsewhere =/ What method did you have in mind for an "appropriate section" ?

n...

User  
0 rated :

Replace the "pi" variable to "PlaylistItem pi = new PlaylistItem("");" and you'll have a 100% chance of crashing when going back

George

JW Player Support Agent  
0 rated :

Hi,

A playlist item with an empty string seems like a different bug.

I mentioned using finish() because I wasn’t able to reliably reproduce by just pressing back when the activity was being populated, so I can’t file a bug report on that yet.

n...

User  
0 rated :

Owh okay, I see. Then download this : https://up2sha.re/file?f=TmJZ4Z3ecYNq

And launch it, press back anytime and it will probably crash the app. The crash log is the same as my initial bug.

George

JW Player Support Agent  
0 rated :

Any particular reason you are not using the latest version of the SDK?
compile ‘com.longtailvideo.jwplayer:jwplayer-core:2.7.0+15’
compile ‘com.longtailvideo.jwplayer:jwplayer-common:2.7.0+15’

n...

User  
0 rated :

Well Gradle is not happy when I use "compile ‘com.longtailvideo.jwplayer:jwplayer-core:+" so I had to manually add the latest version. An update was released since and I wasn't aware of it. I'll try and see if it fixes my issue.

George

JW Player Support Agent  
0 rated :

Hi,

Gradle will show the same warning even with the actual version numbers specified because it detects a + sign.

n...

User  
0 rated :

That's right, that's why I added a "//noinspection GradleDynamicVersion" comment. I forgot about that. I'll be using the latest version from now on.

But it still crashes tho, so the issue is not fixed. Have you been able to reproduce it on your side ?





George

JW Player Support Agent  
0 rated :

I was unable to reproduce the issue on a Nexus 6P running Android 7.1.2

n...

User  
0 rated :

Try on a Nexus 5X emulator ?

Anyway I was able to fix this issue by opening the JWPlayerFragment class in Android Studio, copying its content and pasting it into another class. I surrounded the call to the JWPlayerView.onPause() method with a try-catch block and voilà, no more crash, that was not hard. it will prevent me from using the latest version but well, at least it works now.

n...

User  
0 rated :

Also, you should recycle the TypedArrays of the inflate functions

George

JW Player Support Agent  
0 rated :

Yeah, I usually use the JWPlayerView and make my own Fragments too, especially since the lifecycle methods like onDestroy() sometimes need to be called from onStop().

I don’t trust the emulator for video applications. If you can find when to call finish() in the activity to reproduce the issue that would be the best way to escalate to engineering.

n...

User  
0 rated :

I put onFinish() in the onSetupError listener, it crashes just when I open it. Here is the code : https://up2sha.re/file?f=LnjZHp40J5uH

George

JW Player Support Agent  
0 rated :

Awesome, I was able to reproduce the crash with finish() in onSetupError

n...

User  
0 rated :

Great ! I know it's not the "conventionnal" way of using JWPlayer but it happens in my app if the user goes back too quickly (e.g. finish the activity before the player loads).

George

JW Player Support Agent  
0 rated :

No worries, I’ve escalated the issue to engineering.

n...

User  
0 rated :

Thank you :)

This question has received the maximum number of answers.