PopcornFX / O3DEPopcornFXPlugin

PopcornFX plugin for O3DE
https://www.popcornfx.com/
Other
13 stars 12 forks source link

Sporadic Editor crash on editor-game mode transitions #41

Open mbalfour-amzn opened 1 year ago

mbalfour-amzn commented 1 year ago

I ran into a sporadic crash in the Editor while testing MultiplayerSample which is ultimately due to the fact that PopcornFXIntegration::_Clean() will cause any existing emitter pointers to get deleted, even though other components might still have references to them. Specifically, what seems to be happening is that on the transition from Game Mode back to Editor Mode, PopcornFXIntegration will call _Clean(), and then at some point after that some lingering network packets get processed which attempt to trigger or modify effects spawned via the GameEffect code in MultiplayerSample, which uses the standalone emitter API. Since the GameEffect code didn't know that the emitter pointers were no longer valid, it would call APIs with them and crash.

The GameEffect code has been modified in https://github.com/o3de/o3de-multiplayersample/pull/363 to wrap all the calls in IsEffectAlive() to guard from this happening, but this is a potentially costly workaround - that call is O(N) based on the number of effects - and it would be easy for API users to not know or forget to do. Ideally, we'd have a solution that's a bit more foolproof and cost-effective.

IMO, the solution to the crash could be to do one of the following: