Search Unity

Question SkinnedMeshRenderer particles sometimes randomly disappear

Discussion in 'General Graphics' started by runevision, Mar 29, 2023.

  1. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    I'm seeing an infuriating bug in Unity where particles emitted by SkinnedMeshRenderer sometimes just disappear even though both Animator and SkinnedMeshRenderer is set to update while offscreen.

    Anyone have any clue what could cause this?

    This is in Unity 2019, built-in pipeline, using the regular (Shuriken) ParticleSystem component.

    More details in this video of the issue (contains some gameplay spoilers for Eye of the Temple):


    Only clue I have is that the ParticleSystem bounds visualization is missing at the same times as the particles are missing. However, since bounds are set to update all the time, I don't know why or what to do about it.
     
    Last edited: Mar 29, 2023
  2. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    Hi, long time no see! Hope you are well! :)

    Probably the system is getting culled if it's bounding box is periodically becoming invalid.
    Total guess, but perhaps it is getting an invalid position, such as a NaN.

    I could investigate properly if it's feasible to submit a bug report + repro project?

    To diagnose this yourself, you could try calling ParticleSystem.GetParticles and inspecting the positions for NaN/INF values. However, even if you found some, I'm not sure what you could do to workaround whatever the issue is.
     
    karl_jones likes this.
  3. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    Hi Richard, thanks, I hope you're well as well! :)

    I counted particles with x, y, or z coordinates of positions that are either infinite or NaN but this is all zero every frame, also when the particles are visually missing. Are there other stats I could print out which might help illuminate the issue?

    I also tried setting the Rate over Time to 1 (it's normally 0) to purposefully break procedural mode of the particle system, but this made no difference.

    I also tried changing simulation space from Local to World which some people have said is a workaround, but the particles still go missing regardless (and it changes the visuals significantly).

    Interestingly, when the simulation space is set to World, the moment the particles reappear after having been missing, there's a long particle trail, as if the bird had teleported from a past position to the current one. This seems to imply the issue affects the simulation too, not only the rendering.

    I'll look into whether it's feasible to submit a bug report. :)
     
    richardkettlewell likes this.
  4. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    Thanks for looking at submitting a report, sorry I've no more random ideas to diagnose the cause.
     
  5. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    No problem, thank you too!

    I've submitted a bug report with the title "ParticleSystem particles disappear randomly (c/o Richard Kettlewell)".

    I'll reply again when I receive the bug tracking number.
     
  6. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    CASE IN-36781
     
    richardkettlewell likes this.
  7. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    More info: By printing out the world space bounds of the ParticleSystemRenderer each frame, I can see that the bounds continuously change (as expected) when the particles show correctly, whereas when the particles are missing, the bounds don't update with the bird's position but keep staying the same.
     
  8. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    Is this issue the same perhaps?
    https://issuetracker.unity3d.com/is...meshrenderer-and-model-is-moved-in-lateupdate

    That has a won't fix note saying "Unfortunately this happens due to how the Particle System and Transform system are designed, and to be totally honest - we're not sure how we can fix it."
    But the off thing is that the bug was not there in Unity 5 - it was introduced somewhere in between Unity 5.6 and Unity 2019.4.

    Is there really no workaround in 2019.4? It might help if I better understood what the exact reason for the bug is (e.g. what is it that determines when the particles appear and disappear), which the resolution note in the issue above unfortunately does not shed any light on.

    To be clear, the issue I'm seeing keeps happening if I update the position of the bird in Update instead of LateUpdate, so I'm not 100% sure if it's the same issue.
     
    Last edited: Mar 29, 2023
  9. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    for the linked bug, IIRC, the bounds are 1 frame behind the particles. it doesnt sound like the same thing you are facing?

    That bug was introduced when we switched to our new multithreaded transform update system a few years ago.
     
  10. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    Ok yeah, not the same then, as the bounds are out of date for sometimes long periods of time (many seconds) before suddenly getting updates again.
     
  11. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    Ok, I think there is an obvious workaround I hasn't noticed.

    The particle system had the property "Culling Mode" set to "Pause And Catch-up". After I changed it to "Always Simulate", I can't reproduce the bug any more.

    I guess I never noticed this property before. It didn't exist back in Unity 5.6 which I used to author this particle system effect. I guess it was set to "Pause And Catch-Up" by default when the project was upgraded - not so good when that culling mode is buggy.

    But I'm happy it seems there is a solution!
     
  12. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    Ah, great! Yes Unity always used to do the "pause and catch-up" mode, which could cause terrible performance spikes if it needed to do a big catch-up. So we added the new modes a few years back. Also useful for working around this bug!
    That also confirms that for some reason the system is considered to be "culled" when it shouldn't be!
     
  13. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    All right. The implementation must have been different because the bug I saw here in Unity 2019 didn't happen in Unity 5.

    Since the world space bounds seem to not update when the particles are not simulating, it's tempting to think the issue is that the particles updating depends on the bounds being in view, but the bounds being in view also depends on the particles updating; a circular dependency which would certainly cause issues like this. But this would be so stupid that I'm not sure it can realistically be the actual cause.