Fix the synchronization issue when window is resized or rotated