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

NPE #99

Open
ryust opened this issue Aug 14, 2018 · 5 comments
Open

NPE #99

ryust opened this issue Aug 14, 2018 · 5 comments

Comments

@ryust
Copy link

ryust commented Aug 14, 2018

Is this library being maintained? It seems issues are reported, but not fixed. Every once in awhile my app gets a NPE with the library.

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.postInvalidate()' on a null object reference
at com.plattysoft.leonids.ParticleSystem.onUpdate(ParticleSystem.java:683)
at com.plattysoft.leonids.ParticleSystem.access$100(ParticleSystem.java:38)
at com.plattysoft.leonids.ParticleSystem$ParticleTimerTask.run(ParticleSystem.java:82)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)

@plattysoft
Copy link
Owner

It is watched, but so far there has been no need to maintain it. It seems that every crash report on something like that was a misuse coming for a misunderstanding of how it should be used (and I do agree that it is lacking detailed documentation)

Fell free to fix it and submit a PR.

@ryust
Copy link
Author

ryust commented Aug 14, 2018

So an NPE within the library's internal code is considered a misuse? How can that be? What is the misuse in the above stacktrace?

@plattysoft
Copy link
Owner

Maybe I did not express myself correctly.

As far as I know, all the logged issues on github are linked to wrong usage of the library.

I can not tell what you are doing from a stacktrace, without steps to replicate I can't really find or solve the issue.

You can get plenty of NPE on Android and that is not an issue of the framework (i.e. calling getActivity on a detached fragment)

If you give me steps to replicate, I can look into it, just with a stack trace there's not much I can do.

And finally, as I said, I am happy to accept contributions, so if you want to dig into it and submit a PR with a fix I'll be happy to merge it in.

@ryust
Copy link
Author

ryust commented Aug 15, 2018

As I indicated, the NPE is random and rare... similar to previous reports. The problem was already documented in issue #43 with a user supplied fix. Since the stacktrace (supplied by Crashlytics) doesn't go deep enough to highlight where in my code it starts, I cannot give a reliable example. The app just has a couple simple onetime particle emits... and the same code works most of the time except for a rare NPE.

Maybe at a minimum wrap the onUpdate in a try/catch to more gracefully handle the NPE regardless of the cause?

@plattysoft
Copy link
Owner

Feel free to do a patch, try it and it resolved the problem we can integrate it.
As you can see in the code

The particle system weak reference is only accessed if it is not null, even more, the fact that the previous line executes means that the reference is not null.

Can the reference be turned null between those 2 lines? I can't see how, but as I said, feel free to wrap it on a try/catch and see if that solves the problem. I am reluctant to add something like that to a release just for you to try it out without being sure what is causing it. It may as well surface somewhere else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants