Device Per Pixel Ratio

Is there some way I can make this switchable on an option in the game easily? Just wondering why it’s currently a project option. I can see there’s a maxPixelRatio on the graphicsDevice - is this something I can change and then call something?

I think you can just set graphicsDevice.maxPixelRatio yourself. You can detect the device and set it to what you want. We have a project setting Use Device Pixel Ratio which basically uses whatever window.devicePixelRatio is on the device itself.

Thanks for confirming… Will add some switches :slight_smile:

Please note this issue logged on GitHub:

For the life of me, I simply cannot figure out why this is happening. It could be a bug in mobile Safari. Or it could be a bug in PlayCanvas. I’m just not sure.

Yeah I’ve seen it a couple of times - very rarely and getting the phone to resize by rotating fixes it - but very odd

Oh crap I know what it is! Lol

Had this problem in one of my apps. You are sizing the canvas to 100%, but when you resize the canvas to width/height sometimes it will stretch the body to that pixel size, now 100% is way too big. It is a Safari bug I believe.

I’d be sizing to 100vw, 100vh (and sure, fallback to 100% on older devices) or explicitly setting the pixel size of the canvas to be be innerWidth by innerHeight.

WOW! I hope you’re right! If this is fixed, it’s a BIG deal. :smile:

I’ll see if I can do some tests and verify.

Quick update from me on this.

As you probably know, PlayCanvas apps sit on S3 and are wrapped in another page that is essentially a fullscreen iframe. If I just load the app (rather than loading via the parent iframe), device pixel ratio seems to work OK, and switching ornamentation works fine. But with the iframe, there are problems. Funnily enough, loading stuff in mobile Safari generally works, but things break when the page is saved to home screen and loaded as a fullscreen web app.

I did try changed % to vw/vh but it made no difference.

I really am struggling to fix this. :cry: Any more thoughts on what I can try?

Hey is this still an issue? I see the github issue was marked as resolved for ios 10 but I am still getting this issue. Specifically on an IPad with the game in an iframe (this part is unavoidable for my use case). It’s just as described in the ticket where I start out fine but rotating causes both orientations from then on to be stretched or squished awkwardly.