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

Group.removeEmitter Performance #124

Open
titansoftime opened this issue Oct 25, 2017 · 6 comments
Open

Group.removeEmitter Performance #124

titansoftime opened this issue Oct 25, 2017 · 6 comments

Comments

@titansoftime
Copy link
Contributor

titansoftime commented Oct 25, 2017

I have a particle group with 80 emitters attached (clouds). After an emitter has existed for about 3 minutes I remove the emitter. Unfortunately each Group.removeEmitter call takes between 200 - 300ms on my 3 year old desktop. This of course freezes the app.

This is the culprit code (line 2260):

for ( var attr in this.attributes ) {
    if ( this.attributes.hasOwnProperty( attr ) ) {
        this.attributes[ attr ].splice( start, end );
    }
}

I can just comment this out and all "seems" fine, though I'm sure there is a resulting memory leak (haven't tested).

@squarefeet
Copy link
Owner

Ah, good find! I'm sure you can figure out what that code is doing (and why I thought it necessary). I'll experiment with some perf improvements and do some profiling. What's the longest you'd like it to take (on your current setup?) I'm assuming less than 1 frame, so 16ms at the abs max?

@titansoftime
Copy link
Contributor Author

I'm assuming that the code removes the buffer attributes from the particle group. So huge memory and rendering advantage to remove them.

Hmm, tricky as the operation needs to happen quite quickly, sometimes up to 30 emitters with roughly 300-400 particles per emitter get removed.

I suppose I could just stagger the removal of the emitters, set up some sort of garbage collection. Hmm...

@squarefeet
Copy link
Owner

@titansoftime Do you have an example of your use of this lib so I can try to reproduce it? Or could I just create 30 emitters with 300-400 particles and add/remove them to reproduce?

@titansoftime
Copy link
Contributor Author

Sorry, I've spent the past few days moving. I will get an example fiddle up asap.

@titansoftime
Copy link
Contributor Author

titansoftime commented Nov 17, 2017

And finally.

http://jsfiddle.net/titansoftime/gazta474/

[edited to fix some migration issues]

@squarefeet
Copy link
Owner

Awesome, thanks @titansoftime. I'll have a look as soon as I can!

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