Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where observers could be triggered multiple times for the same event #1472

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

SanderMertens
Copy link
Owner

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:

  1. 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 nested flecs_emit calls happen (which is rare).

  2. 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

…ame event

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:

1. 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 nested `flecs_emit` calls happen (which is rare).

2. 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
@facebook-github-bot
Copy link
Collaborator

This pull request was exported from Phabricator. Differential Revision: D67219403

@facebook-github-bot facebook-github-bot merged commit c511e4e into master Dec 13, 2024
147 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants