Yea that is a somewhat common issue with HDMI and audio - if the device passing it through cant keep up then there can be sync issues. Or the source device can also be a problem (or an app on the source device).
I have found toslink and SPDIF to be both very reliable in this though (probably since they are such mature technologies at this point).
Make sure your TV is actually outputting the correct format over Toslink to your soundbar - many times they default to 2.1 instead of 5.1 or the wrong format (Assuming you have a soundbar with more than just 2.1). A lot of TV's also downmix to 2.1 audio if you pass through a source to them and then use the Toslink output of the TV to a receiver (like say if you did Apple TV --> TV --> Receiver)
I have found toslink and SPDIF to be both very reliable in this though (probably since they are such mature technologies at this point).
Make sure your TV is actually outputting the correct format over Toslink to your soundbar - many times they default to 2.1 instead of 5.1 or the wrong format (Assuming you have a soundbar with more than just 2.1). A lot of TV's also downmix to 2.1 audio if you pass through a source to them and then use the Toslink output of the TV to a receiver (like say if you did Apple TV --> TV --> Receiver)