Page MenuHome

Fix part of T89313: Attribute search crash during animation playback
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Nov 3 2021, 6:45 PM.

Details

Summary

During animation playback, data-blocks are reallocated, so storing
pointers to the resulting data is not okay. Instead, the data should
be retrieved from the context. This works when the applied search
item is the "dummy" item added for non-matches. However, it still
crashes for every other item, because the memory is owned by the
modifier value log, which has been freed by the time the exec function
runs.

I think the solution to that second problem is to allow uiSearchItems
to own memory for every search item, or to adjust the exec callback
so it just gets the UI string, not a pointer to the item. Ideally the
search wouldn't get any pointers at all, I suppose. That seems like
a bigger change though, so I'd like to get feedback on this first.

Diff Detail

Repository
rB Blender
Branch
partial-fix-attribute-search-animation (branched from master)
Build Status
Buildable 18444
Build 18444: arc lint + arc unit

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Nov 3 2021, 6:45 PM
Hans Goudey (HooglyBoogly) created this revision.

The changes look fairly straight forward or reasonable to me.
Support data ownership in uiSearchItems sounds reasonable as well, but I haven't looked into the details of that.

source/blender/modifiers/intern/MOD_nodes.cc
1234

Use ED_object_context.

This revision is now accepted and ready to land.Nov 4 2021, 7:28 PM
  • Merge branch 'blender-v3.0-release' into partial-fix-attribute-search-animation
  • Use ED_object_context
Hans Goudey (HooglyBoogly) marked an inline comment as done.Nov 5 2021, 2:45 PM
Julian Eisel (Severin) accepted this revision.EditedNov 5 2021, 3:58 PM

[...] or to adjust the exec callback so it just gets the UI string, not a pointer to the item. Ideally the search wouldn't get any pointers at all, I suppose. That seems like a bigger change though, so I'd like to get feedback on this first.

The string will not be enough since you can have multiple search results with the same string. E.g. linked data-blocks with the same name, or overriden data-blocks (where the source data-block and the override version of it always have the same name). That's why the pointer is used, but for IDs it would in fact be nicer to use the ID.session_uuid instead.
In a better design you could completely customize how you match items.

For a quick/simple fix you could store what kind of data type the uiSearchItems.pointers contain and do comparisons based on that. Say a uiSearchItems.pointer_type enum. E.g. if string comparison is good enough, the pointer type can be string and UI code does string comparisons. Or maybe best in this case, you use a session UUID as pointer type.

source/blender/modifiers/intern/MOD_nodes.cc
1134

I'd like to avoid passing bContext, especially to lower level functions as much as possible. So I'd suggest just taking const Main * directly here.