Yes, you might be affected by an Apple bug, as explained in the following link. You might find a solution in the following thread.
It might help if you state which version of macOS and which version of KM you are using. Certain versions are impacted differently.
What I would try to do to address your issue is to modify your code to not just move the window, but after the move, check if the move worked by fetching the new window's coordinates, and if the move was not successful, move the window again, repeatedly. (Notice the word "repeatedly.") In my opinion, this will likely fix your problem. but my opinions are correct only 80% of the time.