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

Crash on orientation change on Android 4.3


Hi again,

the JWPayerView crashes on Android 4.3 when the device is rotated. The activity's lifecycle have been properly forwarded to the JWPlayerView.
Used the newest SDK version (2.4.1).
Example project is here: https://asco33@bitbucket.org/asco33/videocrashtest.git

Any way to prevent this?

11 Community Answers

Florian Weigl

User  
0 rated :

Additional info: crash also occurs on Android 4.1.
Exception is:

E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NullPointerException
at android.webkit.WebViewClassic.loadUrlImpl(WebViewClassic.java:2476)
at android.webkit.WebViewClassic.loadUrlImpl(WebViewClassic.java:2492)
at android.webkit.WebViewClassic.loadUrl(WebViewClassic.java:2485)
at android.webkit.WebView.loadUrl(WebView.java:768)
at com.longtailvideo.jwplayer.core.c.c(SourceFile:1370)
at com.longtailvideo.jwplayer.core.c.a(SourceFile:88)
at com.longtailvideo.jwplayer.core.c$4.run(SourceFile:667)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

George

JW Player Support Agent  
0 rated :

Hi,

Looking at your source code, you seem to be missing a few things in you activity tag:

android:configChanges=“keyboard|keyboardHidden|orientation|screenSize”
https://developer.jwplayer.com/sdk/android/docs/developer-guide/getting-started/library-project-setup/

Also, this will handle fullscreening on orientation changes:
https://developer.jwplayer.com/sdk/android/docs/developer-guide/usage/jwplayer-view/

Let me know if you are still running into the problem after adding the code specified

Florian Weigl

User  
0 rated :

Hi George, thanks, I thought that would be optional.
Might be an idea for future releases to get rid of the need for
android:configChanges=“keyboard|keyboardHidden|orientation|screenSize”
because this brings along it's own problems.

Cheers, Florian

George

JW Player Support Agent  
0 rated :

Hello Florian,

What problems are you encountering with the configChanges? The reason they are there is to prevent the Activity lifecycle from running upon rotation as instantiation of the player is expensive and time consuming.

Florian Weigl

User  
0 rated :

For example that the layout is not re-inflated when turning the device, so it's impossible to have landscape-specific layout.

George

JW Player Support Agent  
0 rated :

Hello Florian,

That is up to the developer to find a way they wish to implement that. By default the activity lifecycle happens on rotation and that means the player is re-instantiated and it begins playback from the beginning. Your team will have to find a way to manage their layouts and player state.

Florian Weigl

User  
0 rated :

Hi George,
that's what I mean: "By default the activity lifecycle happens on rotation".
By requiring android:configChanges=“keyboard|keyboardHidden|orientation|screenSize” on every Activity that contains a JWPlayerView (else it will crash), the default Activity lifecycle is broken.

I suggested to work towards getting rid of the need for breaking the default lifecycle.

George

JW Player Support Agent  
0 rated :

I’ll make the suggestion to the engineering team, I think there’s a good reason why they disabled the behavior in the first place.

George

JW Player Support Agent  
0 rated :

Hello Florian,

The engineering team insists that the
android:configChanges=“keyboard|keyboardHidden|orientation|screenSize”
are necessary as any other solution would produce a horrible user experience.

Your team will have to handle orientation changes to produce the UI desired.

Claudio

User  
0 rated :

Please tell to engineering team that this should be optional, I'll take care about user experience. In my app, I'm using JWPlayer in order to reproduce a live audio stream of a radio station and the player is hidden so I don't want that application can be used in landscape mode (because I have other views in the main).

I think this is a bug of JWPlayer since I don't need to listen for "orientation" changes so I don't want to declare that in the manifest.



George

JW Player Support Agent  
0 rated :

Hello Claudio,

Our engineers will prioritize your feature request. No ETA as of yet.

This question has received the maximum number of answers.