Page MenuHome

Fix T68645: Hair Particle Edit - Particle Mirror crash when children are visible in the viewport
ClosedPublic

Authored by Philipp Oeser (lichtwerk) on Sep 11 2019, 1:47 PM.

Details

Summary

Seems to be an issue of not correctly freeing the PTCacheEdit (see T68645 for details), after discussion with sergey we went with the quick and dirty fix to free the path cache early for now. Other solution of freeing it in 'psys_cache_paths' for the non-evaluated psys [which would also fix the particle delete, then undo crash from T69000] needs more deep investigation and, possibly, reconsideration.

Diff Detail

Repository
rB Blender

Event Timeline

From reading i don't see this is necessarily a threading issue, more like some missing update tag or so? Maybe need to do ID_RECALC_PSYS_RESET or ID_RECALC_PSYS_CHILD ?

couple of notes:

  • not a threading issue probably, agree
  • cant get it to work with suggested ID_RECAL flags
  • specifically calling psys_free_path_cache(NULL, edit) is also used by ADD and CUT brush, also done by shape_cut_exec

For the depsgraph side of things:

  • I can see psys_free is called alongside deg_evaluate_copy_on_write:
  • this calls psys_free_path_cache(psys, NULL), so only frees the ParticleSystem pathcache, but not the PTCacheEdit pathcache, hm...
  • a bit later we reach particle_system_update (this gets called, too) > hair_step > psys_update_path_cache > psys_cache_paths
  • this calls psys_free_path_cache(psys, psys->edit) (this should free both ParticleSystem and PTCacheEdit pathcache-- hooray!), but psys->edit is actually NULL here, hm...
  • reminds me of D5758: PTCacheEdit does not live on evaluated object... so will update the diff to use psys_orig_edit_getin that place...
  • if we go with the second suggestion, I can also check for ADD and CUT brush as well as shape_cut_exec (if their usage of psys_free_path_cache(NULL, edit) is obsolete...)
  • particle code still make me a little dizzy, so not sure if I can be of more help here :)
  • I know the old psys is not fun to look at, and is EOL, but I still think we should fix some stuff that is just broken in 2.8 compared to 2.79...

another suggestion regarding the path cache freeing

restore passing psys to psys_free_path_cache (removed by mistake)

Did some look into the particle_edit.c. It seems a lot of code does sequence of

update_world_cos(ob, edit);
psys_free_path_cache(NULL, edit);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
BKE_particle_batch_cache_dirty_tag(edit->psys, BKE_PARTICLE_BATCH_DIRTY_ALL);

So perhaps better to go with your original suggestion.

P.S. I would really love to see this code be more straightforward, but that's separate story :/

source/blender/blenkernel/intern/particle.c
2919–2920 ↗(On Diff #18321)

You are freeing cache for an original psys, but allocating it for evaluated one?
Can't be right.

source/blender/blenkernel/intern/particle.c
2919–2920 ↗(On Diff #18321)

During DEG evaluation:

  • patch frees the original of the PTCacheEdit->pathcache
  • code then allocates for the evaluated ParticleSystem->pathcache, true. [ not looking at this atm., might be another can of worms ;) ]

But regarding the PTCacheEdit->pathcache [ I am only looking at this atm ]:

  • apparently it is neccessary to free the original above, so this works during drawing later [drw_particle_update_ptcache > drw_particle_update_ptcache_edit > PE_update_object > psys_cache_edit_paths]
    • allocation for the new PTCacheEdit->pathcache then happens in psys_cache_edit_paths (if it was free above)

not sure what that tells us?

  • PTCacheEdit only lives on the original? OK...
  • anything that should behave differently? If it lived on the evaluated as well, would it have to be flushed back or something?

Anyways:

  • (a) still think second suggestion should be quite safe? [from what I can tell, and it fixes other things as well...T69000]
  • (b) but could also go with the first suggestion [tried and tested], would then do the same stuff for T69000 again...

What do you think to get this finally of the table: (a) or (b)?
Thanx a whole lot for looking at this btw., I know there is probably more urgent stuff to do.
(I promise not to make many more detours into hair anymore -- even though I dont see this being replaced any time soon?)

For now just follow original proposal (which is currently commented out code in particle_edit.c). That was sufficient AFAIR, and that is how other tools are working here.

Bigger picture needs more deep investigation and, possibly, reconsideration.

back to original suggestion

This revision is now accepted and ready to land.Sep 26 2019, 5:30 PM