Fixed #3369 : Fixed a bug caused by previous solution

In the previous solution, the viewport calculation doesn’t support
WebGL render mode, now the problem is fixed