I switched back [to ASIO drivers] and tweeked the buffers. Don't know if that was the culprit but it hasn't drifted off time sence.
Glad to hear you got it fixed. In my experience, the great majority of these looping sync problems turn out to be hardware/driver/config/synth-specific issues.
One bonafide bug to be aware of is that having a MIDI FX on any track (regardless of which one, and whether enabled or not) will cause SONAR to play some notes from the measure following the end of the loop range, which can have the effect of making things sounds out of sync, though the error should be consistent, not getting progressively worse with each pass. I just confirmed this bug persists in X2.
Personally, I've never been able to replicate a progressively worsening sync error when looping, though I've tried many times with different synths and scenarios in various versions of SONAR over the years when it's been reported by others. This is why I tend to think it's probalby due to some sort of hardware/driver interoperability issue in most cases - possibly involving O/S and even motherboard/chipset-level issues that make it difficult or impossible to troubleshoot remotely.
The worst I ever see is that if you try to null a live MIDI-driven synth against a bounced audio track, you might hear a trace of a transient right at the beginning of the loop, and if you start-stop the project inside the loop, that error may persist throughout the loop. But this error is on the order of a sample or two, does not get progressively worse, and is only audible when doing a null test. You'd never hear it as a timing error in normal circumstances. WDM driver mode seems to be more prone to this than ASIO, which is one reason I prefer ASIO.
This phenomenon may also manifest more with some synths, depending on how consistently they render MIDI to audio from one pass to the next. Session Drummer is not the best in this regard, but again, I wager you'll never be able to hear it unless you're trying to null live MIDI-driven playback against a phase-inverted bounce.
All that said, there
does seem to be an inordinate number of new reports of this drifting sync problem with X2, suggesting that some change might have been made to the audio engine (maybe in conjunction with attempting to make playback more "gapless") that might not be playing nice with some environments.