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

ViewGroup.removeView on null object reference #58

Closed
lesmo opened this issue Feb 1, 2020 · 2 comments
Closed

ViewGroup.removeView on null object reference #58

lesmo opened this issue Feb 1, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@lesmo
Copy link

lesmo commented Feb 1, 2020

Hi! Thanks for this awesome lib! Today I found a weird crash report coming from bootsplash. It has only been reported by a specific device so far, here are the details:

💻 My environment

  • react-native-bootsplash version: 1.2.1
  • react-native version: 0.61.5
  • Platform: Android
  • OS version: 5.0
  • Device: Samsung Galaxy Note 3
  • Android buildToolsVersion: ?

🕵️‍♂️ Reproducing the issue

I'm not sure how, but I think it's kinda my fault but perhaps it should also be addressed by this library if it hasn't already. I got two places where I call the method to hide the bootsplash:

// ... somewhere in my boot "sequence"
useEffect(() => {
  // If for some reason we take more than 2 seconds to boot
  // this hides bootsplash and shows a spinner
  setTimeout(() => RNBootSplash.hide(200), 2000);
}, []);

useEffect(() => {
  // Wait until we're ready to show the splashscreen
  if (platformReady) {
    RNBootSplash.hide(200);
  }
}, [platformReady]);

I'm guessing that the second call to RNBootSplash.hide could fail in this particular config because the View no longer exists and bootsplash doesn't handle that case? I wasn't handling that particular case because... well, I assumed it would just do nothing 😅

This problem doesn't seem to affect any other device yet, but I'll keep an eye on it.

Stacktrace
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.ViewGroup.removeView(android.view.View)' on a null object reference
       at com.zoontek.rnbootsplash.RNBootSplashModule$1$1.onAnimationEnd(RNBootSplashModule.java)
       at android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationEnd(ViewPropertyAnimator.java:1116)
       at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1089)
       at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:666)
       at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:682)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
       at android.view.Choreographer.doCallbacks(Choreographer.java:590)
       at android.view.Choreographer.doFrame(Choreographer.java:559)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:145)
       at android.app.ActivityThread.main(ActivityThread.java:5942)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

🤞Solution

I'm not sure. Perhaps checking if the reference is not null before calling removeView? I'll try to add a check on the React side to avoid calling RNBootSplash.hide twice and see if this fixes the issue for me.

I'm not an Android dev, so I haven't checked the code to see if perhaps that's exactly what happened here.

@zoontek zoontek added the bug Something isn't working label Feb 1, 2020
@zoontek
Copy link
Owner

zoontek commented Mar 7, 2020

@lesmo It has been fixed in the new version: https://github.com/zoontek/react-native-bootsplash/releases/tag/2.0.3 🤘

@zoontek zoontek closed this as completed Mar 7, 2020
@lesmo
Copy link
Author

lesmo commented Mar 11, 2020

Thanks! I'll check it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants