-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
When accessing AudioServer.get_time_since_last_mix() from multiple threads it sometimes (rarely) returns an insanely large number #45025
Comments
Edited issue description with example project. |
Looked into this briefly. I haven't tested anything yet but I'm guessing the bug is here: godot/platform/windows/os_windows.cpp Lines 376 to 377 in 2abe996
In According to the docs for QueryPerformanceCounter, it updates a 64-bit integer with the "performance-counter value, in counts." while the docs for timeGetTime indicate that it returns a 32-bit value in milliseconds. Additionally, the MS Docs for
|
My prior comment is not the issue. Although I am curious what would happen if The issue is that I compiled from source on
Which, because both are So my proposed fix is as follows:
double AudioDriver::get_time_since_last_mix() const {
uint64_t last_mix_time = _last_mix_time;
return (OS::get_singleton()->get_ticks_usec() - last_mix_time) / 1000000.0;
}
|
…e with the AudioDriver lock() and unlock() methods
…e with the AudioDriver lock() and unlock() methods (cherry picked from commit 17ac012)
Godot version: v3.2.4.beta4.official
OS/device including version: Windows 10 Build 18363.1256
Issue description:
AudioServer.get_time_since_last_mix()
sometimes returns a crazy huge result when using multiple threads. Here's some output:I have two threads running analyzing a song as it plays to synchronize gameplay to audio. As part of this I have a function that both threads call fairly regularly:
Initially I was not using the
playback_pos_mutex
like I am now. Adding the mutex has not fixed the issue (I'm pretty sure theAudioServer
is thread-safe anyway according to docs.Steps to reproduce:
I found I can more reliably reproduce the behavior if I click out of the main game window. When it doesn't have focus it seems like the bug happens more often but otherwise it's seemingly random.
Minimal reproduction project: See attached zip below. You'll need the 3.2.4.beta4 for MP3 support. Run the game, select a song and then click out of the window so it no longer has focus. This is not required to reproduce the bug however it makes it happen more reliably.
bug_time_since_last_mix.zip
The text was updated successfully, but these errors were encountered: