GrandOrgue / grandorgue

GrandOrgue software
Other
149 stars 39 forks source link

Fixed hang on Panic button press on MacOs https://github.com/GrandOrgue/grandorgue/issues/1726 #1736

Closed oleg68 closed 6 months ago

oleg68 commented 7 months ago

Resolves: #1726

The reason of hang was

  1. Because GOSound::CloseSound started destroying sound objects
  2. An audio callback waited infinitelly for the sound objects to finish
  3. CoreAudio waited infinitelly for the audio callback to exit

This PR

  1. introduces the GOSound::m_IsRunning flag that allows the audio callback to do anything
  2. GOSound::CloseSound() resets GOSound::m_IsRunning and waits for all callbacks to finish.
  3. GOSound::m_NCallbacksEntered is used for counting of enered audio callbacks and indicating that all ones have been finished
  4. GOSoundGroupWorkItem: fixed bug that it became not finished (m_done = 2 instead of 3) after the threads were stopped
oleg68 commented 7 months ago

@willeke1234 I tried to fix the problems mentioned in #1726

Could you test again?

willeke1234 commented 7 months ago

@Oleg Great, GO doesn't hang anymore. I did get some warnings:

Saturday, 02 December 2023 at 21:14:05: 21:14:04: Warning: GOCondition::WaitOrStop: timeout while GOSoundGroupWorkItem::Finish waited for condition 0x7f83ab29cb98
Saturday, 02 December 2023 at 21:14:05: 21:14:04: Warning: GOCondition::WaitOrStop: timeout while GOSoundGroupWorkItem::Finish waited for condition 0x7f83ab29cb98
Saturday, 02 December 2023 at 21:14:19: 21:14:18: Warning: GOCondition::WaitOrStop: timeout while GOSoundGroupWorkItem::Finish waited for condition 0x7f83ab2a1268
Saturday, 02 December 2023 at 21:14:19: 21:14:18: Warning: GOCondition::WaitOrStop: timeout while GOSoundGroupWorkItem::Finish waited for condition 0x7f83ab2a1268
Saturday, 02 December 2023 at 21:14:19: 21:14:18: Warning: GOCondition::WaitOrStop: timeout while GOSoundGroupWorkItem::Finish waited for condition 0x7f83ab2a1268
oleg68 commented 7 months ago

@willeke1234 could you test the new commit? Do you still receive any warnings on Panic?

willeke1234 commented 7 months ago

@Oleg No hangs, no warnings and no other problems. Thank you!

oleg68 commented 7 months ago

@rousseldenis @larspalo I finished working with this PR. Please review it.

oleg68 commented 6 months ago

@rousseldenis could you approve this PR?