inseven / opolua

A compiled-OPL interpreter for iOS written in Lua
https://opolua.org
MIT License
12 stars 0 forks source link

iPhone 12 mini display is shrunk even though there's room #195

Closed tomsci closed 2 years ago

tomsci commented 2 years ago

See these 3 comparisons, where all simulators are set to "point accurate" and the left edges of the RootView are aligned:

image

Even though there is some spare space on the 12 mini, the RootView is being shrunk compared to the 12 and the iPad views. Given the 12 mini is already a physically smaller device, we could do with making the best use of the space we do have.

jbmorley commented 2 years ago

Well this issue pushed a bunch of buttons thanks to vast amounts of time I invested to get it working consistently and reasonably correctly across all platforms. 😅

Where it all gets nuanced is that in order for the rotation effects to feel right, the screen needs to be centred in the view, which means we need to always take the largest of the platform margins and insets in each axis (max(leading, trailing), max(left, right)) as the insets when determining whether we need to rotate the view or not. This leads to us needing to shrink the screen very slightly in portrait on even an iPhone 13 Pro (thanks to the notch when combined with the navigation bar). I didn't having to do this, but after experimenting with lots of different approaches (allowing the view to move a little vertically, etc), it's the least jarring and seems barely noticeable.

The happy thing is that on an iPhone 13 Pro, the a Series 5 screen fits perfectly when the device is in landscape (we don't have to contend with the notch and the navigation bar), and just scales to fit.

But obviously, it's a one-size-fits-all approach, and this approach will lead to screen scaling on some smaller devices which is what I thought was happening in this bug here (it definitely shrinks the Series 5 screen in landscape on an iPhone SE, which I personally think is an acceptable compromise).

So I went and added my debugging to AutoOrientView (which does all the magic) where we set the background colour to red if we're being scaled, and green if not. And that shows that there's actually no scaling factor required when the iPhone 12 mini is in landscape. So ... I think maybe this bug is in fact invalid. It might look like it, but we're very firmly not applying a scale in landscape.

Portrait (with scale):

Screenshot 2022-02-14 at 08 55 41

Landscape (without scale):

Screenshot 2022-02-14 at 08 55 44
jbmorley commented 2 years ago

I propose we close this as invalid. Though I'd certainly be interested to understand why it looks like it is being scaled to you @tomsci.

jbmorley commented 2 years ago

Well I feel slightly dirty having looked into this more.

It turns out that Apple are actually reporting one screen size to the app on the iPhone 12 mini, and then silently scaling it to 96% to fit it all on screen.

"The 12 Mini is also doing something else to pack more content onto the screen at a smaller size: its standard display resolution is ever so slightly scaled down."

See https://daringfireball.net/2020/11/the_iphone_12_mini_and_iphone_12_pro_max.

That's going to make it very hard to achieve a pixel perfect render on this screen. I briefly futzed around with getting the UIScreen.nativeScale and computing the inverse, then applying that to our root view, but while that does indeed make it the correct size, we're still getting scaled, and then not drawn pixel aligned, meaning that everything still ends up blurry. I think we'd probably have to drop down to a custom layer to be able to draw 'directly' to the pixels and there's a risk that'd be a pretty big change our architecture.

Closing as a very sad won't fix. 😭😭😭