This part is more useful and available to everyone if you put it in `waitForNextPaint`.