Can Corona fix Android orientation change bug? Fails to obey system preferences

Brent: Yay! I will email our users back and tell them a fix may be coming soon. (If I sound frustrated, it’s because I’m channeling what our users have been telling us…)

Thanks again.

Brent: 'evening! It’s been another week and this bug has not been fixed in the latest daily builds (as far as I can tell), so I thought I’d check in. Do you have an updated estimate on when this SDK bug will be fixed?

Thanks!

Hi @corona273,

The engineers are continuing work on this (I’m monitoring their progress, ha ha). This issue has turned out to be anything but low-hanging fruit, unfortunately… there should be a resolution soon though.

Brent

Thanks, Brent, for the update. Please let us know when you have more to share!
 

After lots of headache, this issue is finally resolved.

As Brent said, this turned out to be far from low-hanging fruit. One reason for this is that we needed custom code to handle the auto-rotate setting correctly on API Levels 10-17 for portrait or landscape only apps.

Another reason is that different vendors also have their own ways of handling orientation behaviors, so sifting through these different behaviors and all the edge cases took a significant amount of time to get right.

Anyway, the fix should come in build 2745.

Thank you! We are planning to submit to the play store a new build today that fixes the auto-rotation bug.

We have submitted the build. It seems to be working fine in our on-device testing. Thanks again.

@corona273 can you post your build.settings? Within, you can specify the orientations your app can support. If you don’t list a particular orientation, then your app won’t rotate to that orientation.

As a test, I just locked my device to portrait orientation, then opened an app I built in Corona SDK which only supports landscape orientation, and it  did rotate to landscape, and  would not allow a rotation to portrait. Below are the supported orientations for this app, as listed in my build.settings file:

 orientation = { default = "landscapeRight", supported = { "landscapeRight", }, },

I wouldn’t want my app to force itself into portrait, even if the user has locked their phone to that orientation. Am I misunderstanding your issue? 

UPDATE:  I apologize, I think I did in fact misunderstand, in that you are saying that, if your Corona app lists all orientations in build.settings, and the device has been locked to portrait, the Corona app will still allow rotation to landscape. Is that accurate?

Thanks, Alex. I may not be explaining this properly. You’re talking about apps that support a single orientation; I’m talking about apps that support multiple orientations. In my case the app supports four orientations – here’s an excerpt from build.settings:

supported = { "landscapeLeft", "landscapeRight", "portrait", "portraitUpsideDown", },

If an Android user disables auto-rotate, they expect apps to honor only that orientation and not rotate. Unfortunately Corona SDK-built apps with the build.settings line above will rotate anyway (even when the user has set the system preferences accordingly). This should not happen.

The problem is that the Corona SDK runtime is not reading the system preference. This is a trivial fix but it’s something that Corona needs to do.

PS: The bug is Case 42969.

Alex wrote:

if your Corona app lists all orientations in build.settings, and the device has been locked to portrait, the Corona app will still allow rotation to landscape

Yep, that’s the bug!

You described it more succinctly than I was able to. :slight_smile:

Just got this bug report from a user (yes, the app is live in the Play Store):

Why is the app ignoring my screen rotation settings?? I have it set to portrait mode and no rotation, but still goes to landscape when I turn it sideways. Very annoying when trying to use it while in bed for example. 

It sure would be nice to have this fixed in the next few days…

FYI this is a related thread: https://forums.coronalabs.com/topic/56461-allowing-landscape-orientation-selectively-possible/

@corona273 I realize this would be an ugly hack and could mean additional development time for a feature that is technically a Corona issue, but perhaps you could include do the following:

  1. Only set orientation to support “portrait”.

  2. Have a setting for orientation settings within the app itself.

2a) User can set the app to either  a.  rotate as normal or  b.  stay locked to one orientation.

  1. Create a listener that detects orientation changes, and use it to manually rotate the UI objects to respect the orientation. Examples of this process are described here and here.

Again, this is a fair amount of work (assuming you don’t already have a process for the above) for something that technically should be picked up by Corona’s Runtime. However, if you have the bandwidth to address this, it might work well in your favor. Again, just a suggestion.

I tried out your app and I’m incredibly impressed. Everything feels fantastic and I’ve already given a 5-star review. The polish shows, and I think it’s clear that input from your graphic designer made the app look amazing. Good luck with everything!

Alex: Thanks! But I don’t think I understand. If I have only one orientation–let’s say portrait–defined in build.settings, and the user rotates the device, the listener that would normally detect orientation changes does not fire (I tested this yesterday in the simulator).

So I don’t know how to do what you described. :frowning:

I did some proof-of-concept testing on this a while ago, but if you tested it more recently and found it not working, then I’m more inclined to go with your research. Hopefully Corona can get this fix in quickly!

It’s been a while since I posted this bug last Thursday… Anyone? Rob?

It’s now been over a week and no response from anyone at Corona? This is not exactly encouraging. :frowning:

If I read the notes right, the Engineers have looked into this. I’m trying to translate what they said so bear with me. It appears that the preferences are honored for native apps that depend on the OS to manage orientation. Apps that programmatically control orientation (which we do because we pull the info out of build.settings and set the orientation ourselves).

It’s assigned to an engineer.  Engineering is planning to get back to Android 6 support after we get this public release out. This bug will be dug deeper into as part of our Android 6 support where we will learn more about our ability to address it.

Rob

Thanks, Rob! I appreciate you taking time out of your Saturday evening (and late on a Saturday evening, at that) to reply to pesky screen rotation questions.
 

To clarify one point: This has nothing to do with Android 6 or Android M. The screen rotation lock, which is not supported in Corona SDK, has been in Android for at least 1.5 years. (The article I linked to above discussing it was 1.5 years old.)

It’s growing late here on the left coast and I’m getting a bit tired and may not be thinking clearly, but it strikes me that one way to fix this Corona SDK bug would be for you to add a respectScreenRotationLock boolean in build.settings.

Setting respectScreenRotationLock to false preserves current behavior–as would setting respectScreenRotationLock to true with the system-wide lock setting disabled. What would change is if respectScreenRotationLock is true and the system-wide lock setting is enabled. Then the Corona display canvas would not be resized and rotation/resize events would not be sent.

That seems to be an easy way to fix this bug that would [a] preserve the behavior of existing apps, [b] require no source code changes, and [c] require developers to alter only one line.

I’m happy to talk to your engineers directly if you like. :slight_smile: