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

CommandQueueMT: Fix sync command awaiters missing the chance #91725

Merged
merged 1 commit into from
May 9, 2024

Conversation

RandomShaper
Copy link
Member

@RandomShaper RandomShaper commented May 8, 2024

The recent new implementation of waiting for a sync command to have run used != to compare the sync head with the tail. The problem was that an awaiter could be notified due to thread scheduling at any point after the event. That means that, say, an awaiter of sync command 3 could be awaken by the time sync command 6 has already run.

The fix is not as easy as using < instead because, as stated by a comment in the code, if wraparound ever happened, sync would break. Therefore, this PR adds some logic to reset the counters at the earliest opportunity so they never reach high values.

Also, the mutex is unlocked to give an opportunity to awaiters of realizing the wait is over and go on.

As a bonus, the leftover SYNC_SEMAPHORES constant is removed.

Fixes #91520.

@chrisl8
Copy link
Contributor

chrisl8 commented May 8, 2024

I've tested this repeatedly now and it does appear to solve the issue on all platforms.

@akien-mga akien-mga merged commit c4279fe into godotengine:master May 9, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@RandomShaper RandomShaper deleted the cmd_queue_avoid_skip branch May 9, 2024 07:43
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.

Godot freezes when trying to close project after first open
3 participants