Hello,
I guess this is technically a bug report, but since I am not sure how much of it is because of the engine and how much of it is because of the editor tool chain, I’m posting it here.
I have a problem with the <canvas> element being positioned too high (not vertically centered anymore) after rotating the device in iOS Chrome when a) launching via the editor on launch.playcanvas.com and b) self-hosting. Everything works fine in every other browser I tried, including iOS Safari and Android Chrome. It also works fine in iOS Chrome if I don’t self-host, but instead use the playcanv.as as a host, everything is fine.
The problem is best shown in a video. You will see two elements:
- The WebGL PlayCanvas canvas with the playing field and some PlayCanvas element text on it. As far as I remember, this is fully positioned by the original PlayCanvas CSS itself.
- The HTML UI with the level title in the upper left, the pause button in the upper right and “Touch anywhere to continue.” at the bottom. This is positioned by CSS to be always centered, and scaled via “transform: scale()” by a PlayCanvas script which reacts to
graphicsDevice.on('resizecanvas', ...)
.
On top of the mispositioned canvas, the the CSS transform-scaling doesn’t seem to trigger when rotating from Portrait to Landscape. Sadly I don’t have an iPad at the moment and can’t find out if resizecanvas just isn’t fired or if graphicsDevice reports the wrong width/height. Again: This is only the case in iOS Chrome.
First video: iOS Chrome, Portrait->Landscape->Portrait
- We start in Portrait mode, everything is fine. Notice how “Get out of Damascus” is above the playing field and a bit to the left.
- We rotate to Landscape mode. “Get out of Damascus” (and the whole HTML UI) is suddenly smaller. This is a second problem described; the transform scale didn’t update.
- We rotate back to Portrait mode. Suddenly the <canvas> is much higher.
Second video: iOS Chrome, Landscape->Portrait->Landscape
- We start in Landscape mode. This time, everything is fine. “Get Out of Damascus” is properly postioned and the HTML UI is well scaled, so my scaling seems to work in iOS Chrome Landscape too.
- We rotate to Portrait. Same as step #3 in the last video. (<canvas> too high.)
- We rotate back to Landscape. Same problem as step #2 in the last video. (HTML UI too small, scaling not updated or at all or not updated correctly.)
Third video: iOS Safari. Everything is fine here. Same in Android Chrome.
I can’t share my project, but here is a minimal example project showing the problem. (The buttons and Lorem Ipsum are UI, the grey bar is WebGL. The buttons should be on the left and right corner of the grey bar.)
It also depends on how it is launched/published:
- Launched via editor: Fails in iOS Chrome. (PlayCanvas | HTML5 Game Engine)
- Published on playcanv.as: Works everywhere. (UI Experiments - PLAYCANVAS)
- Self-published: Fails in iOS Chrome. (UI Experiments)
So both problems only exist in iOS Chrome, and only when launching via editor or self-publishing.
I wish I could contribute more to finding out the why, but sadly I don’t have an iPad at the moment. Once I get my hands on one I’ll try to diagnose more. But in the meantime, maybe this bug report helps somebody else find the problem already.
Cheers,
Tobias