-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Android game does not support ScreenOrientation.FullUser #2215
Comments
I'm getting intermittent InvalidOperationException "NaturalOrientation detection failed" crashes on startup in release builds on Android. My best guess is it's a timing issue with the splash screen, but I'm not sure. My preference is to remove the code that throws this exception. It seems unnecessary to try to enforce an orientation setting and we really don't want a released game crashing without a good reason. |
The full error message is "NaturalOrientation detection failed. Set ScreenOrientation in MainActivity to FullSensor." This is by design. |
What exactly is broken? I'm not seeing any issues in my testing with FullUser which is the recommended setting from the Android docs. We want to honor the user's "Don't rotate" setting, right? FullSensor explicitly ignores that setting per the documentation. |
So you have a game that support both landscape and portrait? If you want to propose extending SupportedOrientations and post a PR that implements it, we could get merged. |
Yes, I have games that support both orientations. It’s especially useful on tablets.
If you can tell me what doesn’t work if I just remove this check I’d be happy to work on a fix. I don’t see anything broken after simply removing it so far.
…________________________________
From: Nikos Kastellanos ***@***.***>
Sent: Saturday, February 15, 2025 10:09:06 AM
To: kniEngine/kni ***@***.***>
Cc: David Taylor ***@***.***>; Author ***@***.***>
Subject: Re: [kniEngine/kni] Android game does not support ScreenOrientation.FullUser (Issue #2215)
So you have a game that support both landscape and portrait?
If you want to propose extending SupportedOrientations and post a PR that implements it, we could get merged.
Personally I don't see much value to this for the majority of games.
—
Reply to this email directly, view it on GitHub<#2215 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAS4U76TPNA6E5RON7KI7LD2P5KBFAVCNFSM6AAAAABXEYCWICVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNRQHE3DIMZYGQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
[nkast]nkast left a comment (kniEngine/kni#2215)<#2215 (comment)>
So you have a game that support both landscape and portrait?
If you want to propose extending SupportedOrientations and post a PR that implements it, we could get merged.
Personally I don't see much value to this for the majority of games.
—
Reply to this email directly, view it on GitHub<#2215 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAS4U76TPNA6E5RON7KI7LD2P5KBFAVCNFSM6AAAAABXEYCWICVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNRQHE3DIMZYGQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Mainly, it's that you can control orientation by setting graphics.SupportedOrientations and call graphics.ApplyChanges() at any point. SupportedOrientations was implemented early on, but then it was broken in flavor of setting the orientation directly on the Activity. I think their priority was to enable FullUser as well. Apparently another attempt to enable rotation lock was going on in parallel, as part of replacing OpenTK. The fix that revert all those changes was included in the first release of KNI, along with additional fixes and improvements. The code that handle orientation is very complicated. I did several rewrites to clean it up in order to make it more readable, instead of having to dig 4 methods deep. The work continues even to this day. For example, it might be better to lister for orientation changes from Activity.OnConfigurationChanged(...) instead of detecting it from the accelerometer and set it explicitly on Activity.ScreenOrientation. |
@nkast Thank you for all the work you've put into this feature. Honestly, though, I don't think orientation code belongs in the game engine at all. It's a completely unnecessary complication for me. In all my games I simply support all orientations as far as the game engine is concerned and control the orientation using native platform features such as the Android manifest or iOS info.plist instead. I've never had a need to know the device orientation anyway--only the window bounds. These days with multiple windows possible on mobile devices the effective orientation of the game window can be portrait while the actual device orientation is landscape. So device orientation is misleading anyway and I always go with the window orientation which you can't really control, unless you want to try to disable split screen mode, for example, on iPads. So if it were up to me, I'd remove SupportedOrientations from the engine as well as CurrentOrientation and anything else related to DisplayOrientation. In my opinion this feature in XNA was created for a world that doesn't exist anymore. |
On a related note, I think In my games I've had to handle adding appropriate title safe area bounds in fairly complicated native code that sure would be nice to move into the game engine. For example, I use the window bounds to draw a full screen background which goes under the notches and system controls and rounded screen corners, but then make sure my game UI controls and any important visuals stay inside the native safe area bounds, which requires scaling the native bounds to game engine pixels and handling any changes while the game is running. I expose this as a new If |
KNI Android requires ScreenOrientation.FullSensor, which does not honor the user auto-rotate setting.
Expected: KNI Android should also allow ScreenOrientation.FullUser which honors the user auto-rotate setting.
See https://developer.android.com/develop/ui/compose/quick-guides/content/restrict-app-orientation-on-phones, specifically:
The text was updated successfully, but these errors were encountered: