DanielMartinus / Konfetti

Celebrate more with this lightweight confetti particle system 🎊
ISC License
3.19k stars 301 forks source link

API 21/22 crash during onVisibilityChanged #297

Open ouchadam opened 2 years ago

ouchadam commented 2 years ago

When running konfetti-xml : 2.0.2 on API 21/22 (could also include lower version but haven't tested) the View lifecycle causes a crash. It looks like the constructor is directly calling into onVisibilityChanged causing a NPE as the fields are not yet initialised

Caused by: java.lang.NullPointerException: 
  at nl.dionsegijn.konfetti.xml.KonfettiView.onVisibilityChanged (KonfettiView.kt:3)
  at android.view.View.dispatchVisibilityChanged (View.java:9306)
  at android.view.View.setFlags (View.java:10737)
  at android.view.View.<init> (View.java:4410)
  at android.view.View.<init> (View.java:3891)
  at android.view.View.<init> (View.java:3870)
  at nl.dionsegijn.konfetti.xml.KonfettiView.<init> (KonfettiView.kt:1)
DanielMartinus commented 1 year ago

Thanks for reporting the issue @ouchadam, I'll have to make some time to dive further into this issue. Feel free to clone the project and submit a PR if you already know how to solve the issue and then I'll review the code.