Resizing Renderer (on orientation change) corrupts window.innerWidth/Height

Description of the problem

I may have discovered a very strange bug:

If you adjust the three.js (full-screen) canvas size by calling renderer.setSize(window.innerWidth, window.innerHeight) on resize, switching from landscape to portrait mode messes up window.innerWidth/Height.

Yup, it actually seems to change what window.innerWidth/Height returns.

I have set up a small test case inside this repository.

  1. Open test.html
  2. Fire up Devtools
  3. Toggle Device Toolbar
  4. Select a phone
  5. Switch from landscape to portrait mode and observe console output

This bug also occurs on my android phone with Chrome. It messes up a project real bad I am currently working on and I was able to get rid of the bug by excluding the line renderer.setSize(window.innerWidth, window.innerHeight).

I can add additional information and do further testing if this is not intended behaviour and I didn’t make a mistake.

Three.js version
  • Dev
  • r89
Browser
  • All of them
  • Chrome [v. 63.0.3239.108 (Desktop), v. 63.0.3239.108 (Android)]
  • Firefox
  • Internet Explorer
OS

(As far as I was able to test it)

  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, …)

Author: Fantashit

1 thought on “Resizing Renderer (on orientation change) corrupts window.innerWidth/Height

Comments are closed.