Setting them all to not be visible results in a blank page. Making any one of them visible still causes no problems. Add 2 and the batchadd results in the issue. I tried manually arranging them in height order by changing the "top" value and it worked fine, but only if I had an offset of at least 3 pixels. That led me to re-add the "redundant" autogap statement back in and that that fixes it. Somehow, the autogap was starting as 0.
So, problem solved, and we may have both learned something from this.
If I were to bet, there's probably something to do with the selection outline, but that's sort of spitballing it because I don't know how your code works.