Sound gets off sync and stutters in Source 1 Engine games if system lags/freezes too much for a long duration of time
I tend to reach my maximum ram capacity a lot and so I swap a lot. During these times my whole system lags and sound output in a Source game or other programs skip. When this happens while a Source 1 game is open, after the swapping and lag/freeze has finished, the sound in the game gets off sync and stutters and persists even after the game is restarted (and sometimes after a reboot but that may be another issue with snd_mixahead and is rare). To resolve the sync issue and stutters, pulseaudio -kD or a reboot usually work until the next time I lag/freeze intensely due to swaps. However, the game needs to be closed before the aforementioned command is run or else the audio is silent. The other programs that output sound don't skip and don't have sync issues after the intense swap, it's just the Source 1 game. L4D2 seems the least affected by this from what I've tested, but if the lag is long enough (freeze essentially due to swapping (like 3 - 5 minutes or longer)) then, most of the time, it will have sync and audio issues. Though, sometimes the audio issues occur in shorter periods of lag/freeze. Essentially, it would be great if the audio didn't get off sync and stutter if the system freezes/skips for a period due to swapping or other resource demanding task.
environment
Steps to reproduce
(How one can reproduce the issue - this is very important)
- Have a Source 1 Game open (TF2 or HL2 it is easier to test with and issue happens almost always with these)
- Have a program run that will eat a lot of ram (I tend to have around 80 to over hundred tabs regularly in firefox. The swapping starts around 40 or 60 active tabs of tabs that are open)
- Wait for the swapping for a minute or two if it doesn't stop by then. Either wait for things to settle, spam F4 and wait for things to close, or wait for the oom killer.
- See that the audio is off sync and stuttering in the Source 1 game.
- If you closed the game because you spammed F4 in step 3, the issue should still occur on the next start of the game since pulseaudio hadn't been restarted yet.
What is the current bug behavior?
Swapping or some resource demanding task that causes the system to freeze or sound to skip for a minute or two (sometimes less) causes sound to become off sync and stutter in the game.
What is the expected correct behavior?
The game audio should not be off sync and stuttering after such a lag/freeze and should be normal as before the lag/freeze occurred.
This report was made here since my report on the Source 1 Engine github issues was closed due to the issue being resolved by issuing pulseaudio -kD and being perceived as a pulseaudio problem. Original issue here: https://github.com/ValveSoftware/Source-1-Games/issues/3211