{ "id": "171841", "key": "TIMOB-26157", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "20115", "name": "Release 7.3.0", "archived": false, "released": true, "releaseDate": "2018-08-17" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2018-06-27T22:20:31.000+0000", "created": "2018-06-26T00:53:35.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android", "modal", "opacity", "window" ], "versions": [ { "id": "20115", "name": "Release 7.3.0", "archived": false, "released": true, "releaseDate": "2018-08-17" } ], "issuelinks": [], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2018-06-28T22:14:52.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "*Summary:*\r\nAn app targeting API Level 26 (aka: Android 8.0) or higher will crash with an {{IllegalStateException}} when opening a fixed orientation {{window}} (ie: portrait-only or landscape-only) using properties:\r\n* {{opacity}} set to any value, including {{1.0}}\r\n* {{modal}} set to {{true}}\r\n* {{backgroundColor}} with semi-transparency such as {{\"rgba(255,0,0,138)\"}}\r\n\r\n*Steps to reproduce:*\r\n# Create a Titanium 7.3.0 project.\r\n# Build and run the below code on an Android 8 device.\r\n# Note that the app crashes (or hangs) on startup and fails to display the window.\r\n# Build and run on an Android 7 or older device.\r\n# Note that the app runs just fine.\r\n\r\n\r\n{code:javascript}\r\nvar window = Ti.UI.createWindow({\r\n\topacity: 0.5,\r\n//\tmodal: true,\r\n//\tbackgroundColor: \"rgba(0,0,255,128)\",\r\n\torientationModes: [Ti.UI.PORTRAIT],\r\n});\r\nwindow.open();\r\n{code}\r\n\r\n*Notes:*\r\n* This issue only happens when targeting API Level 26+, which Titanium does by default as of v7.3.0.\r\n* This issue can also be reproduced by using a semitransparent {{backgroundColor}} as well.\r\n* You \"can\" use the {{opacity}} or {{modal}} property as long as you never use the {{orientationModes}} property.\r\n* You \"can\" use the {{orientationModes}} property as long as you never use the {{opacity}} or {{modal}} properties.\r\n* Setting the {{fullscreen}} property to {{true}} does *+not+* appear to work-around the issue as suggested by the exception message.\r\n\r\n*Reason:*\r\nGoogle has introduced a breaking change where you can no longer assign an orientation to a \"translucent\" activity window. Setting the {{modal}} and {{opacity}} properties causes Titanium to use a translucent themed activity window. Calling the Java {{setRequestedOrientation()}} method on such a window will cause the following exception to be thrown.\r\n{code}\r\njava.lang.IllegalStateException: Only fullscreen opaque activities can request orientation\r\n{code}\r\n\r\nNote that this is not an issue if the app targets API Level 25 or lower on an Android 8 device. But lowering the API Level is not a valid work-around since Google Play will soon reject apps which do not target Android 8.\r\n\r\nThis issue can be seen happening to other native Android devs here...\r\nhttps://stackoverflow.com/questions/48072438/java-lang-illegalstateexception-only-fullscreen-opaque-activities-can-request-o\r\n\r\nGoogle's code change that introduced this issue can be seen below. See the Java {{ActivityRecord.setRequestedOrientation()}} method.\r\nhttps://github.com/aosp-mirror/platform_frameworks_base/commit/39791594560b2326625b663ed6796882900c220f#diff-960c6fdd4a4b336d98b785268b2a78ff\r\n\r\n*Work-Arounds:*\r\n* If you need to use the {{orientationModes}} property, then you cannot use the {{modal}} or {{opacity}} properties.\r\n* If you need to use the {{modal}} or {{opacity}} properties, then you cannot use the {{orientationModes}} properties, which means the window will support all orientations.\r\n* No other work-around is known for the moment... other than to mock your own modal/semitransparent window using views instead.\r\n", "attachment": [], "flagged": false, "summary": "Android: A semi-transparent or modal Window with a fixed orientation crashes on Android 8", "creator": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "438745", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR (master): https://github.com/appcelerator/titanium_mobile/pull/10134", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-06-27T02:55:13.000+0000", "updated": "2018-06-27T02:55:13.000+0000" }, { "id": "438746", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Note that this PR catches the exception and logs the error. This PR does not attempt to \"force\" the Android OS to apply a fixed orientation to a semi-transparent or modal window. Meaning that the given orientation will be ignored and the window will use the default {{SCREEN_ORIENTATION_UNSPECIFIED}} setting which supports all orientations (but honors the orientation-lock setting).\r\n\r\nThis appears to be something Google no longer supports (why? who knows) and we didn't want to go against the grain. The error message states that if the app is fullscreen and hides the app title bar, then fixed orientation should be allowed, but I haven't been successful in doing so yet.", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-06-27T03:02:16.000+0000", "updated": "2018-06-27T03:02:16.000+0000" }, { "id": "438774", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Can we do a 7_3_X for this?", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-06-27T17:28:26.000+0000", "updated": "2018-06-27T17:28:26.000+0000" }, { "id": "438777", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "That's the plan. Was waiting for a code review first.", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-06-27T18:24:12.000+0000", "updated": "2018-06-27T18:24:12.000+0000" }, { "id": "438782", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR (7.3.x): https://github.com/appcelerator/titanium_mobile/pull/10138", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-06-27T21:05:34.000+0000", "updated": "2018-06-27T21:05:34.000+0000" }, { "id": "438841", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix in SDK 7.3.0.v20180628132121.\r\nNo crash or app hang seen.\r\nClosing.\r\n\r\nStudio Ver: 5.1.0.201806280846\r\nSDK Ver: 7.3.0.v20180628132121\r\nOS Ver: 4.2.13\r\nXcode Ver: 7.0.4\r\nAppc NPM: 1.1.3\r\nAppc CLI: 10.13.5\r\nDaemon Ver: Xcode 9.4.1\r\nTi CLI Ver: 5.1.1\r\nAlloy Ver: 1.12.0\r\nNode Ver: 8.9.1\r\nNPM Ver: 5.5.1\r\nJava Ver: 10.0.1\r\nDevices: ⇨ google Nexus 5 --- Android 6.0.1\r\n ⇨ google Nexus 6P --- Android 8.1.0\r\nEmulator: ⇨ Android 8.0.0\r\n", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-06-28T22:14:45.000+0000", "updated": "2018-06-28T22:14:45.000+0000" } ], "maxResults": 8, "total": 8, "startAt": 0 } } }