Fixed a bug that causes a crash when the viewport size is zero.