-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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 possible crash at exit on iOS #11781
Conversation
61c2194
to
7201a14
Compare
7201a14
to
116e735
Compare
@@ -726,7 +726,8 @@ void AudioServerSW::_thread_func(void *self) { | |||
|
|||
while (!as->exit_update_thread) { | |||
as->_update_streams(true); | |||
OS::get_singleton()->delay_usec(5000); | |||
if (OS::get_singleton()) | |||
OS::get_singleton()->delay_usec(5000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a little suspect. We just sleep in hopes of avoiding a race?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sleeps a little to avoid calling _update_streams all the time and eat a lot of cpu.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could change this if (OS::get_singleton()) for an ERR_BREAK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it isn't to avoid a race I guess this is OK, but how do we know this is the right amount of time to wait? Can't we have some kind of callback?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We process the audio in its own thread, which I think its great we take advantage of multiple cores and also avoid taking process time from the main thread, so a callback would be a bad idea in my opinion. And the timer has been like this for a long time I think so I don't want to mess with it, and 5ms if fine in my opinion.
Fixes the crash described at #11623 which happens when the iOS app tries to quit and the render callback keeps getting called (because AudioDriverIphone::finish wasn't clearing the property).