Debugging…
So, on init you call self.create_custom_events
which registers the undo callback self.track_undo
- this in turn calls self.list_widget_update()
So dependency flow: create_custom_events --> track_undo --> list_widget_update
Next list_widget_update calls several internal functions (I’m skipping calls that look like PyQt calls):
-
utils.get_scene_cameras()
a. Looks ok, not sure what,
res = apkg_utils.find_closest_parent(cam, "apkgStack")
is doing - is this doing large scene querying? - might be a slow down.
-
self.refPlanes.get_all_ref_planes() - looks fine.
-
utils.get_visibility(img_plane) - looks fine.
-
self.update_camera_combo() - looks good.
Rough understanding here - you want to query image planes in the scene when the uses hits undo/redo by the looks of it. It gets called 6 times and seems to do the heavy lifting in the interface both getting cameras and planes.
Your undo context looks correct - not sure if you need chunk name a module member if its always the same thing.
What might be the kicker is this callback:
kf_edit_event = OpenMayaAnim.MAnimMessage.addAnimKeyframeEditedCallback(self.node_update)
This method registers a callback that is called whenever an
a group of keys are modified. The callback is invoked once per
atomic change to single or group of keyframes. For example, if
a user selects a group 5 of keys and moves them 5 units in the value
axis, then a single callback event will be invoked with a MObject
> for each of the 5 keyframes. The MObjects can then be used in the
MFnKeyframeDelta function set. Refer to MFnKeyframeDelta function set
documentation for more info.
Emphasis mine - are you working with lots of keys? It’s going to rebuild the interface for every key even if they are moved/changed as a group.
Can you disable the node event callbacks and test if the undo one functions correctly without lag - I feel something else is going on here.