We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4577 - SDL_GetWindowDisplayMode/SDL_GetWindowSize returning incorrect result on iPhone 8 Plus
Summary: SDL_GetWindowDisplayMode/SDL_GetWindowSize returning incorrect result on iPho...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.1
Hardware: iPhone/iPod touch iOS 11
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.10
Depends on:
Blocks:
 
Reported: 2019-04-03 20:00 UTC by Dan Ginsburg
Modified: 2019-05-26 21:59 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Ginsburg 2019-04-03 20:00:14 UTC
I'm running on an iPhone 8 Plus on iOS 12.2.  For review here are its display values for the iPhone 8 Plus (from https://developer.apple.com/library/archive/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/Displays/Displays.html#//apple_ref/doc/uid/TP40013599-CH108-SW2)

nativeBounds (Pixels): 1080x1920
UIKit Size (Points): 414x736
nativeScaleFactor (not Zoomed): 2.608
scale (UIKit Scale Factor): 3

What happens is that in UIKIt_GetDisplayModes:

uimode.size.width = 1242
uimode.size.height = 2208

This is the UIKit Size (414x736) times the UIKitScale factor (3).

I expect the mode to be returned in points, which should be 414x736.  However, it instead returns 476x846 [1242x2208]/2.608.  The reason it does this is because of this code:

#ifdef __IPHONE_8_0
        /* The UIScreenMode of an iPhone 6 Plus should be 1080x1920 rather than
         * 1242x2208 (414x736@3x), so we should use the native scale. */
        if ([data.uiscreen respondsToSelector:@selector(nativeScale)]) {
            scale = data.uiscreen.nativeScale;
        }
#endif

If I remove that code from UIKit_GetDisplayModes, it returns the correct values.  

That code has been there since this commit:

https://hg.libsdl.org/SDL/rev/dbe19a0cad97

The change that commit made to SDL_uikitopengles.m makes sense to me, but I'm not sure why the change to UIKit_GetDisplayModes was made.  I'd propose to delete the code from UIKit_GetDisplayModes, but I'm not sure if there was something that was counting on it.
Comment 1 Ryan C. Gordon 2019-05-18 18:48:54 UTC
Tagging a bunch of bugs with "target-2.0.10" so we have a clear list of things to address before a 2.0.10 release.

Please note that "addressing" one of these bugs might mean deciding to defer on it until after 2.0.10, or resolving it as WONTFIX, etc. This is just here to tell us we should look at it carefully, and soon.

If you have new information or feedback on this issue, this is a good time to add it to the conversation, as we're likely to be paying attention to this specific report in the next few days/weeks.

Thanks!

--ryan.
Comment 2 Alex Szpakowski 2019-05-26 21:59:29 UTC
This was fixed by https://hg.libsdl.org/SDL/rev/c9410703cbdd