Fix issue where observers could be triggered multiple times for the same event #1472
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.
Summary:
This diff fixes a Flecs issue where mulit-component observers could get triggered multiple times for the same event. Two separate problems contributed to this issue:
Observers copied the wrong event id used to dedup events. Instead of using the event id passed by
flecs_emit
, observers used the global event id counter. In most cases these are the same, except when nestedflecs_emit
calls happen (which is rare).The event id was copied at the wrong time. When a multi-component observer gets triggered, it still needs to verify if the event matches its query. Observers copied the event id before checking if the query matched, which could cause events to get skipped or delivered multiple times.
Differential Revision: D67219403