plattysoft / Leonids

A Particle System for standard Android UI: http://plattysoft.github.io/Leonids/
Apache License 2.0
2.28k stars 398 forks source link

Bug causing crash #113

Open Kishor103 opened 3 years ago

Kishor103 commented 3 years ago

The particle system is causing crash in some devices. The crash report is as follows:-

Fatal Exception: java.lang.NullPointerException Attempt to invoke virtual method 'void android.view.View.postInvalidate()' on a null object reference

com.plattysoft.leonids.ParticleSystem.onUpdate (ParticleSystem.java:683) com.plattysoft.leonids.ParticleSystem.access$100 (ParticleSystem.java:38) com.plattysoft.leonids.ParticleSystem$ParticleTimerTask.run (ParticleSystem.java:82)

gs666 commented 3 years ago

same question...

plattysoft commented 3 years ago

I am curious as how did the drawingView became null. Maybe the app was put into the background and the views destroyed while the animation was still running?

Do you have any insights on that? Or on Android version, or on how frequent it is?

Looks like it could be easily solved by adding a try catch and canceling the animation inside the catch.

HXZg commented 3 years ago

I use TimerTask to launch and call the cancel method. This happens occasionally.

Now I use stopEmitting instead of cancel