Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid draw on iOS 8 when both Portrait and Landscape mode enabled. #3040

Closed
ebatiano opened this issue Oct 1, 2014 · 17 comments · Fixed by #3116
Closed

Invalid draw on iOS 8 when both Portrait and Landscape mode enabled. #3040

ebatiano opened this issue Oct 1, 2014 · 17 comments · Fixed by #3116

Comments

@ebatiano
Copy link

ebatiano commented Oct 1, 2014

An app, where both display modes are avaliable (landscape and portrait), when in Portrait mode, app displays like it is still in landscape.

screenshot

@beeradmoore
Copy link

Just found that I have to keep portrait on as well as landscape left/right.
By setting graphics.SupportedOrientations to landscapeleft and landscaperight fixes this issue, however rotating it around gives similar results with the screen having black however there is only a corner of the screen blue (not exactly 1/4 for some reason). Not at computer to post screenshot but when I was investigating the issue was caused by DisplayOrientation.LandscapeLeft not LandscapeRight.

@beeradmoore
Copy link

Apparently this was fixed as of #2940
Looks like I am going to have to add source into my game instead of using nuget packages to fix this. No biggie I guess.

@danzel
Copy link
Contributor

danzel commented Oct 15, 2014

You can grab a built version of monogame from the build bot too:
http://teamcity.monogame.net/
Click artifacts next to the mac and grab the ios dlls (Use the refs/...evelop version)

@ebatiano does this fix it for you too?

@ebatiano
Copy link
Author

Unfortunately no, it didn't.
Issue #2940 is about landscape mode. My problem appears when both modes are enabled. When rotating phone and changing orientation, this happens.

@danzel
Copy link
Contributor

danzel commented Oct 16, 2014

Looks like the rotation happened but the screen resolution didn't update to match

@danzel
Copy link
Contributor

danzel commented Oct 16, 2014

@picobots - any idea?

@picobots
Copy link
Contributor

Ooh, that's an interesting one. I've never used both Portrait and Landscape in the same game, but I can do some digging. I'm guessing the width/height values are getting reversed (just like they were in iOSGameViewController.LoadView) wherever the rotation code executes—I just don't know where that happens. I can dig around, but if anyone knows which file rotation is handled in, let me know.

@picobots
Copy link
Contributor

Hmm, well, I'm at a loss. I just did a solution-wide search for .Landscape, and it looks like someone already fixed just about every instance of reversed width/height (or maybe they were never reversed in those other files in the first place). Pretty much everywhere uses the correct Min/Max calculation for setting width/height. I only found these two that don't:

https://github.com/mono/MonoGame/blob/develop/MonoGame.Framework/Graphics/PresentationParameters.cs#L183-L198

#if IOS
    // Mainscreen.Bounds does not account for the device's orientation. it ALWAYS assumes portrait
    var width = (int)(UIScreen.MainScreen.Bounds.Width * UIScreen.MainScreen.Scale);
    var height = (int)(UIScreen.MainScreen.Bounds.Height * UIScreen.MainScreen.Scale);

    // Flip the dimentions if we need to.
    if (TouchPanel.DisplayOrientation == DisplayOrientation.LandscapeLeft || TouchPanel.DisplayOrientation == DisplayOrientation.LandscapeRight)
    {
        width = height;
        height = (int)(UIScreen.MainScreen.Bounds.Width * UIScreen.MainScreen.Scale);
    }

    backBufferWidth = width;
    backBufferHeight = height;
#else

https://github.com/mono/MonoGame/blob/develop/MonoGame.Framework/iOS/GamerServices/KeyboardInputViewController.cs#L134-L148

    if (InterfaceOrientation == UIInterfaceOrientation.LandscapeLeft || InterfaceOrientation == UIInterfaceOrientation.LandscapeRight)
    {
        var tmpkeyboardSize = keyboardSize;
        keyboardSize.Width = Math.Max(tmpkeyboardSize.Height, tmpkeyboardSize.Width);
        keyboardSize.Height = Math.Min(tmpkeyboardSize.Height, tmpkeyboardSize.Width);
    }

    var view = (KeyboardInputView)View;
    var contentInsets = new UIEdgeInsets(0f, 0f, keyboardSize.Height, 0f);

But I wouldn't think either of those is affecting the screen/display. (Side note though: The first one might be related to this issue?)

@tomspilman
Copy link
Member

Thanks for your work on this @picobots . We need help on the iOS side of things for sure.

@beeradmoore
Copy link

@danzel , getting the dll from teamcity seemed to do the trick for my issue.

Here is a sample project that I made that shows the issue. Has rotation set to landscape left/right in the Info.plist and orientation set to landscape set to left/right in code as well.
http://files.bradmoore.com.au/xamarin/monogame/RotateTest001.zip
It includes the dll I got from teamcity (branch 3093, build 1438), but also has the packages from nuget included so they may auto download and add themselves to the project for you.

@ebatiano
Copy link
Author

@ytn3rd, the issue is not about landscape mode. It's about apps, where both: landscape and portrait modes are enabled.

@beeradmoore
Copy link

Ohhhhhh.... my bad.

@picobots
Copy link
Contributor

@ebatiano: I don't have a ton of time to dig much deeper right now, but I'm happy to help out if you can narrow this issue down. Since you have a project that reproduces the issue, maybe you could step through a couple of the MonoGame code locations where .Landscape is checked and see what values are getting set for width/height? That may help pinpoint what's going on here.

@tomspilman
Copy link
Member

@ebatiano @picobots @ytn3rd

Can you guys try the simple fix proposed here...

#3098

... see if it improves things.

@ebatiano
Copy link
Author

@tomspilman I'll check this fix on Sunday, unless someone checks it earlier.

@picobots if #3098 doesn't fix this I'll dig more into it.

@ebatiano
Copy link
Author

Unfortunately #3098 didn't fix this one. I'll dig more into it.

@ebatiano
Copy link
Author

ebatiano commented Nov 6, 2014

#3116 fixed this.

@ebatiano ebatiano closed this as completed Nov 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants