You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Andrew McMillan (JIRA)" <ji...@apache.org> on 2018/03/29 10:51:00 UTC

[jira] [Comment Edited] (CB-13491) NullPointerException in Splash Screen on Android

    [ https://issues.apache.org/jira/browse/CB-13491?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16418753#comment-16418753 ] 

Andrew McMillan edited comment on CB-13491 at 3/29/18 10:50 AM:
----------------------------------------------------------------

I'm still seeing this on some phones, using version 5.0.2 of the plugin.

Just looking at the code for line 225...227 of SplashScreen.java :

{{if (fadeSplashScreenDuration > 0 && forceHideImmediately == false) {}}
 {{    AlphaAnimation fadeOut = new AlphaAnimation(1, 0);}}
 {{    fadeOut.setInterpolator(new DecelerateInterpolator());}}

it seems pretty clear that creating the AlphaAnimation must be failing on some devices (I'm seeing it on "Samsung Galaxy A5(2017) (a5y17lte), 3072MB RAM, Android 7.0" according to the ANRs report on the Play Store)

A reasonable fix would seem to be to move line 226 to before line 225 and check for null in that give up on attempting to animate there, something like:

{{AlphaAnimation fadeOut = new AlphaAnimation(1, 0);}}
 {{if (fadeOut == null || (fadeSplashScreenDuration > 0 && forceHideImmediately == false)) {}}
 {{    fadeOut.setInterpolator(new DecelerateInterpolator());}}

 
 Or perhaps more pedantically:

{{AlphaAnimation fadeOut = null;}}
 {{if (fadeSplashScreenDuration > 0 && forceHideImmediately == false) fadeOut = new AlphaAnimation(1, 0);}}
 {{if (fadeOut != null) {}}
 {{    fadeOut.setInterpolator(new DecelerateInterpolator());}}

 


was (Author: karora):
I'm still seeing this on some phones, using version 5.0.2 of the plugin.

Just looking at the code for line 225...227 of SplashScreen.java :

{{if (fadeSplashScreenDuration > 0 && forceHideImmediately == false) {}}
 {{    AlphaAnimation fadeOut = new AlphaAnimation(1, 0);}}
 {{    fadeOut.setInterpolator(new DecelerateInterpolator());}}

it seems pretty clear that creating the AlphaAnimation must be failing on some devices (I'm seeing it on "Samsung Galaxy A5(2017) (a5y17lte), 3072MB RAM, Android 7.0" according to the ANRs report on the Play Store)

A reasonable fix would seem to be to move line 226 to before line 225 and check for null in that give up on attempting to animate there, something like:

{{AlphaAnimation fadeOut = new AlphaAnimation(1, 0);}}
 {{if (fadeOut == null || (fadeSplashScreenDuration > 0 && forceHideImmediately == false)) {}}
 {{    fadeOut.setInterpolator(new DecelerateInterpolator());}}

 
 Or perhaps more pedantically:

{{AlphaAnimation fadeOut = null;}}
 {{if (fadeSplashScreenDuration > 0 && forceHideImmediately == false) fadeOut = new AlphaAnimation(1, 0);}}
 {{if (fadeOut == null) {}}
 {{    fadeOut.setInterpolator(new DecelerateInterpolator());}}

 

> NullPointerException in Splash Screen on Android
> ------------------------------------------------
>
>                 Key: CB-13491
>                 URL: https://issues.apache.org/jira/browse/CB-13491
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-plugin-splashscreen
>         Environment: Being reported on multiple devices including: 
> Moto G4 Play
> Galaxy S6 
> LG K20 Plus
> Galaxy S8+
> Samsung Galaxy On5
> LG K8 V
> LG K20 plus
> HTC ONE
> LG Aristo
> LG V20
> Slate 8
> LG X power
> Motorola DROID Turbo
> LG Stylo 2
> LG K7
> Moto E
> Being reported on multiple versions including:
> Android 7.1
> Android 7.0
> Android 6.0
> Android 5.1
>            Reporter: Carey Pfaff
>            Priority: Critical
>              Labels: android, cordova-7.0.1, splashscreen
>
> Multiple crash logs are being reported with the error below. The app is using cordova-plugin-splashscreen version 4.0.3.
> java.lang.NullPointerException:
> at org.apache.cordova.splashscreen.SplashScreen$4.run (SplashScreen.java:227)
> at android.app.Activity.runOnUiThread (Activity.java:5874)
> at org.apache.cordova.splashscreen.SplashScreen.removeSplashScreen (SplashScreen.java:217)
> at org.apache.cordova.splashscreen.SplashScreen.onMessage (SplashScreen.java:187)
> at org.apache.cordova.PluginManager.postMessage (PluginManager.java:312)
> at org.apache.cordova.CordovaWebViewImpl.postMessage (CordovaWebViewImpl.java:377)
> at org.apache.cordova.splashscreen.SplashScreen$2.run (SplashScreen.java:163)
> at android.os.Handler.handleCallback (Handler.java:751)
> at android.os.Handler.dispatchMessage (Handler.java:95)
> at android.os.Looper.loop (Looper.java:154)
> at android.app.ActivityThread.main (ActivityThread.java: 6165)
> at java.lang.reflect.Method.invoke (Native Method)
> at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:888)
> at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:787)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org