2 ms·
Can someone provide a good quality example of code that would bug on system clock updates? I have a hard time thinking about one. Especially as these system clo
by ascar 8y ago
Can someone provide a good quality example of code that would bug on system clock updates? I have a hard time thinking about one. Especially as these system clock updates shouldn't change the time for more than a few seconds, at least if you have automatic updates turned on (and the fix in the article is to turn that off). I'm not interested in examples that shouldn't have made it through a merge request in the first place. It's not about the actual bug that happened here, but more about general things to think about that can go wrong with system time updates.
I can think about two main use cases for system time: Measuring time elapsed, most notably for timeouts, and scheduling something in the future (which can be done with a timestamp instead of time elapsed). Maybe I'm already missing some important ones here.
In the time elapsed use case a time shift into the future might delay something for these few seconds, which shouldn't result in more than a lag. A shift into the past might trigger a timeout, but a timeout that triggers on a few seconds should be a handled error.
In the schedule use case a time shift into the future shouldn't make any difference. You can't assume it's run at exact times anyway and always use "should happen after", i.e. greater than timestamp. A time shift into the past might only delay it a bit, still no reason for a bug.
What am I missing?
- spiralganglion 8y agoI believe I’ve had this issue, manifesting as skips and glitches only a fraction of a second long, like a pop or click. Total conjecture apropos of nothing, this issue could be that the system clock update does something synchronous or blocking in the T2, introducing a very brief interruption to audio scheduling.
- vortico 8y agoThis bug is caused by the Mac time daemon stealing 10ms+ of resources from the scheduler (perhaps because of it being a wrong thread priority, or the clock hardware taking a very long time to respond to an update request? who knows), not because audio drivers use the real time value for any reason (they don't).