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

Sample App is not responding after continuously touching for long time in FollowCursorExampleActivity #38

Closed
datpt91 opened this issue Feb 15, 2016 · 6 comments

Comments

@datpt91
Copy link

datpt91 commented Feb 15, 2016

As I mention above, after touching continuously for several minutes, sample app will be not responding. If I increase to several ParticleSystem, it will be faster to not responding.

The problem can be it just create new ParticleSystem objects, but after using it. The app still keep memory for those object without free them and continuously create new objects when touching. (I don't see you have function to free the memory).

It will be great if you can fix this issue and destructive objects after using them. Thank you very much for your time.

@datpt91
Copy link
Author

datpt91 commented Feb 15, 2016

If you need me to provide Video and Log file, just me know!

@plattysoft
Copy link
Owner

This works as intended.

A particle system does create a pool of particles and attaches itself to the view hierarchy. It is meant to be used in one of the following ways:

  • As a continuous emitter for as long as the view is active
  • As a oneShot that is used once when the view is active
  • As a oneShot that is triggered several times

If you want to create multiple particle systems and make them auto-release once the oneShot is completed, you need to add a listener there and remove the particle system from the View hierarchy.

As I said, that is not the way it is intended to work, you should create a few particle systems and reuse them, but if you really want to go that way, the solution is what I stated before.

@datpt91
Copy link
Author

datpt91 commented Feb 22, 2016

Dear Mr Raul,
Thank you very much for your detail explanation.
First of all, I tried to define ParticleSystem object in onCreate rather
than in onTouch in your example but it will lead to force close program.

Second thing is with oneShot it doesn't specify emit point position like
emit(). Which I do is using only one single view on screen and divide it to
many regions to identify touch areas with different effects. I use your lib
as kid mode. So maybe they can play with it for long time.

If you have any ideas for this problem, could you please let me know.

Thank you again for all your help.
On Feb 19, 2016 6:30 AM, "Raul Portales" notifications@github.com wrote:

Closed #38 #38.


Reply to this email directly or view it on GitHub
#38 (comment).

@plattysoft
Copy link
Owner

The position is calculated based on the parent view, setting the position was a later addition for special cases like the follow touch example.

It should be possible to create a particle system during onCreate, as long as it is done after setContentView.

You can change the position anytime using the same method and then call oneShot. If it does not, that is a bug that should be solved (I haven't tried that particular case myself).

In this case, each time the user clicks, the oneShot will move, so if it is clicked before the previous one finishes there could be a visual glitch.

I suggest you create a pool of ParticleSystems and dynamically change the position and call oneShot, adding a listener when the oneShot is completed to return the particle system to the pool.

Given that each ParticleSystem creates a View to draw with, a small number should be easy to manage (that is also the cause of the unresponsiveness on your case)

The other solution is to create a method that finalizes the oneShot by removing the particle system from the view hierarchy.

The first solution (pool) is probably easier.

@datpt91
Copy link
Author

datpt91 commented Feb 23, 2016

Thank you very much for your help, it works well now. I already handled
memory issue.

2016-02-22 17:46 GMT+07:00 Raul Portales notifications@github.com:

The position is calculated based on the parent view, setting the position
was a later addition for special cases like the follow touch example.

It should be possible to create a particle system during onCreate, as long
as it is done after setContentView.

You can change the position anytime using the same method and then call
oneShot. If it does not, that is a bug that should be solved (I haven't
tried that particular case myself).

In this case, each time the user clicks, the oneShot will move, so if it
is clicked before the previous one finishes there could be a visual glitch.

I suggest you create a pool of ParticleSystems and dynamically change the
position and call oneShot, adding a listener when the oneShot is completed
to return the particle system to the pool.

Given that each ParticleSystem creates a View to draw with, a small number
should be easy to manage (that is also the cause of the unresponsiveness on
your case)

The other solution is to create a method that finalizes the oneShot by
removing the particle system from the view hierarchy.

The first solution (pool) is probably easier.


Reply to this email directly or view it on GitHub
#38 (comment).

@plattysoft
Copy link
Owner

Good to know, I hope this thread is useful for someone else in your situation.

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