Fix infinite loop in getViewportWidthInCssPixels