Adobe-Runtime-Support icon indicating copy to clipboard operation
Adobe-Runtime-Support copied to clipboard

[iOS] Odd orientation change event behavior in iOS 16

Open cturner-crestron opened this issue 2 years ago • 1 comments

Device OS: iOS AIR SDK: 33.1.1 build 929 Reproduced on the iPhone 8, iPhone XR and iPhone 13. I suspect it's reproducible on all iPhones.

Problem Description

We've run into some odd behavior regarding orientation events. This problem is causing issues for our customers running iOS 16. In my test, I take an iPhone and rotate it slowly completing a full 360 degree rotation of the device.

On iOS 15, we receive ORIENTATION_CHANGING followed by ORIENTATION_CHANGE for the default and upsideDown orientations. I believe this is correct.

On iOS 16, we receive ORIENTATION_CHANGING followed by ORIENTATION_CHANGE, followed by another ORIENTATION_CHANGING event, but only for the rotatedRight orientation. After those 3 events fire, we don't receive any more orientation events.

Steps to Reproduce

Here's a snippet of the relevant code:

`
stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, reorientListener); stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, fadingListener);

    private function reorientListener (e:StageOrientationEvent):void
    {
        if (e != null) {
            _extensionInterface.log(FlashEventDefines.LOG_SEV_DEBUG, _nativeLogCategoryId, "StageOrientation Event: " + e.toString());
        }
    }
    
    private function fadingListener (e:StageOrientationEvent):void
    {
        if (e != null) {
            _extensionInterface.log(FlashEventDefines.LOG_SEV_DEBUG, _nativeLogCategoryId, "OrientationChanging: StageOrientation Event: " + e.toString());
        }
    }

`

Here is the resulting logging showing the incorrect events on iOS 16:

iOS15:

2022-09-27T18:22:58 DEBUG Core3Host OrientationChanging: StageOrientation Event: [StageOrientationEvent type="orientationChanging" bubbles=false cancelable=true beforeOrientation="default" afterOrientation="upsideDown"] 2022-09-27T18:22:58 DEBUG Core3Host StageOrientation Event: [StageOrientationEvent type="orientationChange" bubbles=false cancelable=false beforeOrientation="default" afterOrientation="upsideDown"] 2022-09-27T18:23:03 DEBUG Core3Host OrientationChanging: StageOrientation Event: [StageOrientationEvent type="orientationChanging" bubbles=false cancelable=true beforeOrientation="upsideDown" afterOrientation="default"] 2022-09-27T18:23:04 DEBUG Core3Host StageOrientation Event: [StageOrientationEvent type="orientationChange" bubbles=false cancelable=false beforeOrientation="upsideDown" afterOrientation="default"]

iOS16:

2022-09-27T18:18:39 DEBUG Core3Host OrientationChanging: StageOrientation Event: [StageOrientationEvent type="orientationChanging" bubbles=false cancelable=true beforeOrientation="default" afterOrientation="rotatedRight"] 2022-09-27T18:18:39 DEBUG Core3Host StageOrientation Event: [StageOrientationEvent type="orientationChange" bubbles=false cancelable=false beforeOrientation="default" afterOrientation="rotatedRight"] 2022-09-27T18:18:39 DEBUG Core3Host OrientationChanging: StageOrientation Event: [StageOrientationEvent type="orientationChanging" bubbles=false cancelable=true beforeOrientation="rotatedRight" afterOrientation="rotatedRight"]

Known Workarounds

Using the orientation lock button on the iOS control panel seems to prevent this issue.

cturner-crestron avatar Sep 27 '22 22:09 cturner-crestron

So having investigated this one (thanks for the help @cturner-crestron) we need to make an update which requires us to build with the iPhoneOS 16 SDK .. which we're not yet doing. So as a temporary solution we are creating an ANE for this -> below as a zipped up version along with a simple test case to demonstrate its usage.

The issue happens because the XML descriptor says "any" in the aspect ratio field, but then the aspect ratio is later on being programmatically restricted to "portrait". In iOS 16, we now need to tell the OS explicitly that the allowed values have changed..

Please let us know of any feedback on the attached.. thanks

aspect_ratio_ane.zip

ajwfrost avatar Oct 05 '22 16:10 ajwfrost

Hi @ajwfrost I tried the ANE and it seems to do correctly. But to test on the iOS 16 Device I get the compilation error Compilation failed while executing : ld64 Packaging output: Undefined symbols for architecture arm64: "_objc_msgSend$keyWindow", referenced from: _SetAspectRatio in libcom.harman.AIRiOSAspectRatioHandler.a(iOSAspectRatioHandler.o) "_objc_msgSend$rootViewController", referenced from: _SetAspectRatio in libcom.harman.AIRiOSAspectRatioHandler.a(iOSAspectRatioHandler.o) "_objc_msgSend$sharedApplication", referenced from: _SetAspectRatio in libcom.harman.AIRiOSAspectRatioHandler.a(iOSAspectRatioHandler.o) "_objc_msgSend$setNeedsUpdateOfSupportedInterfaceOrientations", referenced from: _SetAspectRatio in libcom.harman.AIRiOSAspectRatioHandler.a(iOSAspectRatioHandler.o) ld: symbol(s) not found for architecture arm64

Could you maybe resolve this? The rotation problem is damaging the app and it would be great to send the update as fast as possible. Also on iPad with iOS 16 is the rotation problem significant. The iPad moves to portrait mode, even if landscape is set. I am using SDK 50.0.1.1

apofis1969 avatar Nov 02 '22 16:11 apofis1969

This Link. Here Andrew posted an Ane to temporary resolve the rotation problem. But can not create a build to test https://github.com/airsdk/Adobe-Runtime-Support/issues/2170

apofis1969 avatar Nov 03 '22 10:11 apofis1969

@apofis1969 are you compiling on Windows or on macOS? I think those issues (certainly that last one) are because the ANE was built using iOS 16 ("setNeedsUpdateOfSupportedInterfaceOrientations" is a new API that's only present in iPhoneOS SDK from 16 onwards... and resolves the issue that only happens in iPhoneOS 16 onwards... so basically any earlier app needs to be re-built using the latest SDK).

So potentially this is going to need the iPhoneOS 16.0 SDK for linking against. We're just finalising the updates to switch to the latest SDKs and Xcode so would then provide all the updated stub libraries that are created from the 16.0 SDK and that would then fix this link error (on both Windows and mac)

thanks

ajwfrost avatar Nov 03 '22 10:11 ajwfrost

@ajwfrost thanks for the fast reply. Yes I am building on Mac. Unfortunately I can not upgrade my Mac. It is from 2016. I will wait for the update to fix the rotation problem. Hopefully you are able to release within the next days.

apofis1969 avatar Nov 03 '22 11:11 apofis1969

@ajwfrost Hi, I tried the ANE on the iOS 16.1 Simulator, but I get the Error: 3500 How to fix this? I also created a symlink ld64, but does not help too. I use SDK 50.0.1.1 At the real iPhone with iOS 16.1 the Ane works, but the rotation is still odd. Adobe Air does not dispatch the native rotation in the same speed as the iOS 16 does it. The iPhone needs to be already in landscape or portrait before moving to the destination screen. Switching between portrait and landscape screens is the problem

apofis1969 avatar Nov 08 '22 17:11 apofis1969

@ajwfrost hi, the new sdk still does not work with the aspekt ratio ane. When will this be available, please? Compilation failed while executing : ld64 Packaging output: Undefined symbols for architecture arm64: "__ZN9CSWFDecen13NeedsMoreDataEPKhS1_jPj", referenced from: __ZN12ScriptPlayer11PushDataBufEPKhiPbb in libRuntimeHMAOT.arm-air.a(splay.o) "_objc_msgSend$keyWindow", referenced from: _SetAspectRatio in libcom.harman.AIRiOSAspectRatioHandler.a(iOSAspectRatioHandler.o) "_objc_msgSend$rootViewController", referenced from: _SetAspectRatio in libcom.harman.AIRiOSAspectRatioHandler.a(iOSAspectRatioHandler.o) "_objc_msgSend$sharedApplication", referenced from: _SetAspectRatio in libcom.harman.AIRiOSAspectRatioHandler.a(iOSAspectRatioHandler.o) "_objc_msgSend$setNeedsUpdateOfSupportedInterfaceOrientations", referenced from: _SetAspectRatio in libcom.harman.AIRiOSAspectRatioHandler.a(iOSAspectRatioHandler.o) ld: symbol(s) not found for architecture arm64

apofis1969 avatar Nov 11 '22 21:11 apofis1969

FYI we have a new SDK available now which will solve this for iOS, when building from a mac. But an issue with it when building from Windows that we're still working on.. See https://airsdk.harman.com/download/50.1.1.1

ajwfrost avatar Nov 24 '22 15:11 ajwfrost

Hi @ajwfrost, Any schedule on the next release (I'm on Windows).

marcanw avatar Dec 08 '22 07:12 marcanw

If you mean, getting the iOS development available again from Windows .. this is taking us a while I'm afraid, the code has moved on a lot since Adobe last cross-compiled it and we don't have access to the same build environments. There are so many dependencies on macOS specific headers that it's causing us quite a headache to try to build it. (Anyone else who fancies having a go.. please feel free, it's just the linker from Apple's open source github repo...!)

ajwfrost avatar Dec 08 '22 08:12 ajwfrost

I was looking for a solution on the new orientation issue with iOS16.

marcanw avatar Dec 08 '22 08:12 marcanw

Yes, sorry, the only way for this currently is with AIR 50.1 on macOS..

ajwfrost avatar Dec 08 '22 09:12 ajwfrost

Hence my question for Windows. If I could have a timing, it would help me for my release plan.

marcanw avatar Dec 08 '22 09:12 marcanw

It's a tricky one to estimate I'm afraid.. I would hope we have it done before Christmas, but it's already taken longer than I would initially have expected...

ajwfrost avatar Dec 08 '22 09:12 ajwfrost

I faced the similar issue with the orientation change and solved it by manualy defining orientation on Event.RESIZE rather than StageOrientationEvent.ORIENTATION_CHANGE:

stage.addEventListener(Event.RESIZE, onRESIZE);
function onRESIZE(event:Event):void{
	var stageW = stage.stageWidth < stage.stageHeight ? Math.min(Capabilities.screenResolutionX, Capabilities.screenResolutionY) : Math.max(Capabilities.screenResolutionX, Capabilities.screenResolutionY);
	var stageH = stage.stageWidth < stage.stageHeight ? Math.max(Capabilities.screenResolutionX, Capabilities.screenResolutionY) : Math.min(Capabilities.screenResolutionX, Capabilities.screenResolutionY);
	var orientation = stageW > stageH ? "landscape" : "portrait";
}

I'm using stageWidth and stageHeight since Capabilities values update are late.

Hope it helps you.

MalacTheLittle avatar Jan 13 '23 12:01 MalacTheLittle

Adding iOS 16 note that setting 'stage.autoOrients' to 'false' fails to prevent/lock auto orientation. Built an iOS package with AIR 50.1.1.2 on Windows and the issue still occurs.

amorganiv avatar Feb 10 '23 19:02 amorganiv