Particle engine crashes when removing emitters
by Robert Elek · in Torque Game Engine · 12/01/2003 (8:04 am) · 25 replies
First of all: i'm using torque 1.2.
The full patch can be found here:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4899
---
Note: this patch requires the improved particle emitters patch
You can find it here..
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4096
I see that particle engine crashes, at end of mission (when removing all emitternodes/emitters).
The problem is that while removing the emitternode/emitter, the advanceTime method gets invoked (code is not thread-safe?) and tries to work with the currently destructed emitter/emitternode.
This is a problem, when the machine is slow, and advancetime is called with a greater probability while destructing.
I've fixed one bug with in particleemitter.cc, adding:
it was a big problem, emitternode is destructed first, then the emitter referenced the destructed node.
but it still has problems:
destructed particles are accessed from PEngine (which is invoced from ParticleEmitter::advanceTime)..
i think advanceTime and onRemove should be made mutually exclusive.
if you have a better idea for this, or a ready-to-go patch, i will appreciate it :)
If not, tomorrow i will patch it and post a resource on it..
Please help me :)
The full patch can be found here:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4899
---
Note: this patch requires the improved particle emitters patch
You can find it here..
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4096
I see that particle engine crashes, at end of mission (when removing all emitternodes/emitters).
The problem is that while removing the emitternode/emitter, the advanceTime method gets invoked (code is not thread-safe?) and tries to work with the currently destructed emitter/emitternode.
This is a problem, when the machine is slow, and advancetime is called with a greater probability while destructing.
I've fixed one bug with in particleemitter.cc, adding:
void ParticleEmitterNode::onRemove()
{
removeFromScene();
if (isClientObject()) {
mEmitter->LinkObject = NULL; // fixed by robymus: shutdown hanging
mEmitter->deleteWhenEmpty();
mEmitter = NULL;
}
Parent::onRemove();
}it was a big problem, emitternode is destructed first, then the emitter referenced the destructed node.
but it still has problems:
destructed particles are accessed from PEngine (which is invoced from ParticleEmitter::advanceTime)..
i think advanceTime and onRemove should be made mutually exclusive.
if you have a better idea for this, or a ready-to-go patch, i will appreciate it :)
If not, tomorrow i will patch it and post a resource on it..
Please help me :)
#2
I'm getting sure the it is not a multithread problem - but what then? :)
I see that the problem is not with the objects, but the datablocks associated with the objects.
When ending a mission and advanceTime is called, ParticleEngine::updateSingleParticle tries to access its parameters's (particle and emitter) datablocks, which are not present - possibly destructed previously.
It's getting more and more interesting, as it produces a random crashing.
I'd be happy to get some idea for this :)
I think totally understanding the object destruction mechanism of torque would take too much time for me.
12/02/2003 (6:57 am)
I have now a clearer sight of the problem.I'm getting sure the it is not a multithread problem - but what then? :)
I see that the problem is not with the objects, but the datablocks associated with the objects.
When ending a mission and advanceTime is called, ParticleEngine::updateSingleParticle tries to access its parameters's (particle and emitter) datablocks, which are not present - possibly destructed previously.
It's getting more and more interesting, as it produces a random crashing.
I'd be happy to get some idea for this :)
I think totally understanding the object destruction mechanism of torque would take too much time for me.
#3
12/02/2003 (10:11 am)
Try using a SimObjectRef<>... Check simBase.h. It'll be sort of ugly but it should fix the crashing.
#4
I've just posted a resource with the patches, i hope it will get moderated soon.
12/03/2003 (5:45 am)
Thanks Ben, I've used SimObjectPtr and that way I could check if the datablocks are released yet.I've just posted a resource with the patches, i hope it will get moderated soon.
#5
When switching missions (on more servers) my client sometimes dies. The details are described here:
www.garagegames.com/mg/forums/result.thread.php?qt=14840
I wanted to try the posted fix but my source does not compile with the changes:
I am now doing a cvs update and hope it will solve the problem.
12/18/2003 (7:05 am)
I am experiencing some troubles I believe is connected to the problem described in this thread. When switching missions (on more servers) my client sometimes dies. The details are described here:
www.garagegames.com/mg/forums/result.thread.php?qt=14840
I wanted to try the posted fix but my source does not compile with the changes:
particleEmitter.cc(144): error C2039: "LinkObject" : is not a member of "ParticleEmitter"
I am now doing a cvs update and hope it will solve the problem.
#6
01/05/2004 (5:46 am)
I have now updated to Release_1_2_0 and I still get the above error!?
#7
01/05/2004 (11:33 pm)
Has anyone posted a bug report on this issue?
#8
As for a bug report - go look, the bug tracker is open to all SDK owners. :)
01/06/2004 (10:23 am)
Go update to HEAD. Any fixes to the problem will be in there.As for a bug report - go look, the bug tracker is open to all SDK owners. :)
#9
I still cannot compile the posted fix.
I have looked for a bug report and there is none.
I could post the bug report but I think Robert Elek has a better understanding of the actual problem. As for me I just have some problems that could very well be coursed by the problem described by Robert. My client crashes when jumping from server to server when there are a lot of particle effects in the mission you are jumping from.
01/07/2004 (12:21 am)
Well, I have updated to HEAD and there seem to be no changes in that area.I still cannot compile the posted fix.
I have looked for a bug report and there is none.
I could post the bug report but I think Robert Elek has a better understanding of the actual problem. As for me I just have some problems that could very well be coursed by the problem described by Robert. My client crashes when jumping from server to server when there are a lot of particle effects in the mission you are jumping from.
#10
Sorry, my fix is working only if the improved particle emitter patch is applied before..
I've forgotten about this..
You can find it here..
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4096
01/07/2004 (2:49 am)
Lasse:Sorry, my fix is working only if the improved particle emitter patch is applied before..
I've forgotten about this..
You can find it here..
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4096
#11
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4899
01/07/2004 (2:57 am)
Anyway, i have posted a more complete patch here:www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4899
#12
Unfortunately the patch did not solve my problem :(
Somewhere in this thread the fix was mentioned as being ugly. Are there any plans to solve the problem at hand in a non-ugly manner? A fix that migth be added to CVS?
I hope a future solution might solve my problem :D
01/13/2004 (5:17 am)
Thanks for the additional information.Unfortunately the patch did not solve my problem :(
Somewhere in this thread the fix was mentioned as being ugly. Are there any plans to solve the problem at hand in a non-ugly manner? A fix that migth be added to CVS?
I hope a future solution might solve my problem :D
#13
I think a non-ugly fix could only be done by redesigning the particle engine :(
01/14/2004 (5:52 am)
The fix is ugly because I don't have a detailed understanding of the particle engine and I couldn't find a better solution for now.I think a non-ugly fix could only be done by redesigning the particle engine :(
#14
01/14/2004 (11:18 am)
The particle engine needs to be loved. :(
#15
No, honestly my only problem is when I do a swicth of servers/missions, where the cleanup seems to crash the engine - but we really need this functionality (the switching) in the game, we are making - so it is kind of a show stopper :( :(
01/14/2004 (10:47 pm)
Can you please teach me how to love it? - Every time I see a particle effect in the game I start shooting at it :DNo, honestly my only problem is when I do a swicth of servers/missions, where the cleanup seems to crash the engine - but we really need this functionality (the switching) in the game, we are making - so it is kind of a show stopper :( :(
#16
05/03/2004 (9:03 am)
Have you tried manually deleting all particle effects before the mission transfer?
#17
How do you suggest I go about it?
Should I put all particle effects in a named group in the mission file and then traverse the group before the mission transfer, deleting all particle effects?
The main problem with this solution is that such a deletion would be done serverside - would it not? That is: all particle effects would be deleted serverside and would be removed for all clients still in the mission (clients who stay behind).
How do I delete the effects clientside?
05/03/2004 (10:51 pm)
No, I have not tried manually deleting the effects in script - if this is what you have in mind.How do you suggest I go about it?
Should I put all particle effects in a named group in the mission file and then traverse the group before the mission transfer, deleting all particle effects?
The main problem with this solution is that such a deletion would be done serverside - would it not? That is: all particle effects would be deleted serverside and would be removed for all clients still in the mission (clients who stay behind).
How do I delete the effects clientside?
#18
05/05/2004 (10:43 am)
The group approach sounds good.
#19
Clients change missions one at a time, when they themselves choose todo so!
Ergo the deletion of particles should be handled clientside!?
Now the question is, can the deletion be done clientside?
05/05/2004 (11:16 pm)
Yes, the group approach sounds mighty tempting but will result in unwanted sideeffects for all clients still in the given mission - would it not?Clients change missions one at a time, when they themselves choose todo so!
Ergo the deletion of particles should be handled clientside!?
Now the question is, can the deletion be done clientside?
#20
05/06/2004 (9:28 am)
Of course. You put all client side particle emitters in a simgroup then blast the simgroup.
Associate Kyle Carter
I haven't run into that bug before, though, so go ahead and do a patch, I'll look over it when you get it done.