fix(python): fix event routing sender mismatch for playhead events#300
Closed
richardssam wants to merge 1 commit into
Closed
fix(python): fix event routing sender mismatch for playhead events#300richardssam wants to merge 1 commit into
richardssam wants to merge 1 commit into
Conversation
Resolve issue where playhead events (position_atom, etc.) were silently dropped in the Python API. When C++ event groups broadcast messages, the sender is set to the owner actor (e.g. Playhead) rather than the event group address. - Add actor_to_callback_uuid_ map in EventToPythonThreadLockerActor to track the optional owner actor per callback ID. - Route incoming messages via the owner actor address as a fallback when the sender does not match any event-group key. - Implement broadcast_down_atom handler to purge stale callback entries when a subscribed owner actor dies, preventing a SIGSEGV on timeline switches where the old playhead is torn down mid-dispatch. - Update subscribe_to_event_group in module.py to pass the owner actor as the third argument to add_message_callback. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
Sorry, ignore this its a duplicate. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issues
N/A
Summarize your change.
Fixes
EventToPythonThreadLockerActorso that playhead and selection eventssubscribed from Python are actually delivered, and prevents a SIGSEGV crash
when the subscribed actor is torn down during a timeline switch.
Describe the reason for the change.
When a C++ event group (e.g. a Playhead's broadcast group) sends a message, the
CAF sender is the owner actor (the Playhead itself), not the event-group
actor that the Python code subscribed to.
EventToPythonThreadLockerActorlooked up callbacks by sender address, found no match, and silently dropped the
message. This meant
subscribe_to_playhead_eventsand similar subscriptionsdelivered nothing.
A second problem: the
broadcast_down_atomhandler was a TODO no-op. When thesubscribed owner actor died (e.g. on a timeline switch), any in-flight message
attributed to its address was dispatched to a now-invalid
callback_func,causing a signal 11 (SIGSEGV) crash.
Describe what you have tested and on which operating system.
Tested on macOS: a Python plugin using
subscribe_to_playhead_eventsnowreceives
position_atomevents on every frame change. Timeline switches (whichtear down and recreate the Playhead actor) no longer crash the application.
Add a list of changes, and note any that might need special attention during the review.
src/python_module/src/py_context.cpp:callback_to_event_group_map (Uuid → caf::actor) to track whichevent-group actor owns each callback, enabling correct
leave_broadcastwhen a subscription is cancelled.
(events_source, owner_actor, callback_id)messagehandler that registers
owner_actor's address as an additional routing keyfor the same callback, so messages sent by the owner are routed correctly.
broadcast_down_atomhandler: on actor death, walkactor_to_callback_uuid_for the dead address, erase the correspondingentries from
callback_to_event_group_, then remove the actor entry.leave_broadcastsend into the Uuid-cancellation handler so ituses
callback_to_event_group_for O(1) lookup instead of a linear scan.py_add_message_callbackto accept an optional third argument(owner actor), passing it to the new 3-argument handler when present.
Note for reviewers: the
broadcast_down_atomfix addresses a latent crashthat would have occurred for any Python subscription whose source actor could
be destroyed at runtime (playheads, selection actors). The original TODO
comment acknowledged this was unfinished.
python/src/xstudio/api/module.py:subscribe_to_event_grouppasses the owner actor as the third argument toadd_message_callbackwhen one is available.If possible, provide screenshots.
N/A
This was developed with the assistance of claude code.