I've recently begun to update an AIR app for both iOS and Android that was originally published with AIR 4 to use the latest AIR SDK 16.
By default the app is set to allow both Landscape and Portrait by setting the app.xml to <aspectRatio>any</aspectRatio> and all the UI resizes to fit the width/height.
Then, through code I do a little math to determine if it's a large or small device, and if small, I set the aspect ratio to be Landscape as soon as the app begins.
var resolutionX:Number = Capabilities.screenResolutionX; var resolutionY:Number = Capabilities.screenResolutionY; var numDiagonalInches:Number = Math.round(Math.sqrt((resolutionX*resolutionX)+(resolutionY*resolutionY)))/Capabilities.screenDPI; MainData.SMALL_DEVICE = (numDiagonalInches<6)?true:false; if(MainData.SMALL_DEVICE){ this.stage.setAspectRatio(StageAspectRatio.LANDSCAPE); }
This code worked correctly with the version of AIR it was published, but trying on the latest AIR 16 there is a very weird and easy to reproduce bug.
The bug ONLY happens when the app is launched in the Portrait Mode. When the app launches in portrait mode with its initial aspect ratio set to any, we detect its small and set the aspect ratio to Landscape. Everything looks fine until you turn the device 180 degrees... Now all of a sudden the app rotates what seems like 270 degress and becomes stuck and will never fix itself, rendering the app completely useless.
Here is a video demonstration of the bug: AIR 16 aspect ratio bug - YouTube