I have done more tests on other machines, and here’s what I can conclude so far:
For #1: The canvas size is sometimes bigger than project size (even with NoScale), depending on devicePixelRatio. This may be expected?
For #2: The high dpi setting is returning different values for window size, when devicePixelRatio is not 1.0. This is NOT expected.
Assuming browser zoom is 100% and desktop scale is also 100%, devicePixelRatio should be 1.0. However I believe for some retina displays, and depending on browser used, devicePixelRatio is not necessarily 1.0.
On my Windows 10 PC (retina):
- Chrome reports devicePixelRatio of 1.1, so actual canvas size is multiplied by 1.1 (704x396) even with NoScale
- Edge somehow reports devicePixelRatio of 1.0 that’s why there is no issue here
On 2 other Windows 10 PC (1 retina, 1 regular):
- Chrome and Edge both report devicePixelRatio of 1.0 so I can not reproduce the issue
On my Macbook Pro (retina):
- Chrome and Safari BOTH report devicePixelRatio of 2.0, so actual canvas size is multiplied by 2.0 (1280x720) even with NoScale. However, I am getting window size results of 1280x720 or 640x360 depending on high dpi setting again.
My expected results:
High dpi on/off should return consistent values whatever its setting is. Right now, there are different results, even if the actual canvas size remains the same.
Now for canvas size, what is expected is either one of these:
- If we want to respect devicePixelRatio, then canvas size may really be bigger than project size sometimes, even if NoScale is specified. This is currently how it works.
- If we want to respect NoScale setting instead, and expect canvas size to be exactly the same as project size (pixel wise), then devicePixelRatio should be ignored when determining the canvas size.
I am ok with #1, now that I understand how it works. Probably best to mention that in the manual for future reference though i.e. canvas size will always be multiplied by devicePixelRatio (I assume this is how it works for the other scale modes too). In the case of NoScale, canvas size is not necessarily the same as project size if devicePixelRatio is not 1.0.
No, it’s not expected. It may be bigger only if page zoomed. If you set “No Scale” external container size always should have size as you specify in game.project.
Previous time you told me that you made screenshot with zoom 110%
Again, let’s try to finish with the first issue. Because sometimes you and then I make conclusions based on data from the console. But issue #1 is about container size, we shouldn’t take into account console data, but we can check the size in Inspector like this:
Yes you’re right! It’s also reporting 640x360 canvas size for me.
And yes I made sure my page zoom is 100%
My confusion is because I incorrectly assumed that the actual pixel size would also be the same. If you measure the actual pixel size from the screen shot, it’s really 704x396 pixels. I was expecting that to still be 640x360 (since my page zoom is 100%), but you made me aware of this devicePixelRatio thing (mine is still 1.1 in Windows Chrome, even if page zoom is already 100%).
So yes, I think it’s safe to assume that #1 is a non-issue, sorry about that. In the test project, project size is indeed the same as canvas size for NoScale. I guess just don’t expect pixel size to be the same, because of devicePixelRatio, which is dependent on a couple of things (e.g. Windows 10 scale/layout also changes this, not just browser page zoom).
Thanks for clearing things up for me. I’m learning new things in the process.