If you need to output the correct screen height and width when the device screen is rotated, very often the orientation sensor cannot keep up. You need to use a clock with a setting of 50-100 msecs in order to cdapture the correct values
CREDITS: Boban on the Kodular Forum