Solution: External cooling.
I was having the same issue, but today found the source. It seems the issue is either the internal cooling system is underperforming or the on-board graphics controller has gained increased sensitivity to heat.
For the first year of using my SP4, I had no such issue. I constantly monitor internal temperature and have never run hotter than mid-60s. Recently however after using my device for an extended period unplugged or a shorter amount of time while plugged in, the lines and screen desync occur.
I tested the heat damage idea by using my SP4 while plugged in for half of the day today. I watched videos, used the pen, and had multiple programs running with no screen issues. The key here is that I set up a desk fan to blow cold air onto the SP4.
So to prevent the lines and display desync, you need some kind of fan or external cooling for your SP4. I'd say start with a small/cheap USB fan, and if that isn't powerful enough move to something bigger. Be sure the fan is aimed at the top left corner of the back because that's where most of the heat localizes.