{ "id": "171932", "key": "TIMOB-26213", "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": "20214", "description": "", "name": "Release 7.2.1", "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-08-06T23:28:19.000+0000", "created": "2018-07-14T15:44:40.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "android", "exitonclose", "window" ], "versions": [ { "id": "19333", "description": "Patch release for important items that did not make it into 6.0.3", "name": "Release 6.0.4", "archived": false, "released": true, "releaseDate": "2017-04-27" } ], "issuelinks": [], "assignee": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2018-08-08T21:36:07.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": "I want to use {{exitOnClose:false}} on my root window, so it will go into background and is not exiting. It works fine unless I close a child window with the {{homeAsUp}} back arrow. \r\n\r\n*Example:*\r\n{code}\r\nvar win = Ti.UI.createWindow({backgroundColor: \"#fff\",exitOnClose: false});\r\nvar btn = Ti.UI.createButton({title: 'open'});\r\n\r\nbtn.addEventListener('click', function() {\r\n var win2 = Ti.UI.createWindow({backgroundColor: \"#fff\"});\r\n var actionBar;\r\n\r\n win2.addEventListener(\"open\", function() {\r\n if (Ti.Platform.osname === \"android\") {\r\n if (win2.activity) {\r\n actionBar = win2.activity.actionBar;\r\n if (actionBar) {\r\n actionBar.displayHomeAsUp = true;\r\n actionBar.onHomeIconItemSelected = function() {win2.close();};\r\n }\r\n }\r\n }\r\n });\r\n win2.open();\r\n});\r\nwin.add(btn);\r\nwin.open();\r\n{code}\r\n\r\n*Example video:* https://migaweb.de/open_window.mp4\r\n\r\n*Steps to reproduce*\r\n* First three times I open the index and close it and open it again (was in background, seeing no splashscreen -> works fine)\r\n* After that I open the second window two time and close it with the back button and then the index window, too (same, works fine)\r\n* Last time I close the second window with the homeAsUp button and I end up at the splashscreen when I close the index. After that I ALWAYS end up at the splashscreen unless I kill the app\r\n\r\n*Tested versions:*\r\nAndroid 7\r\nHTC A9\r\nTi SDK 7.2.0.GA, 7.3.0.v20180711185043\r\n\r\n*Expected behaviour*\r\nAlways go to background and don't show the splashscreen when {{exitOnClose}} is set to false on the root window.", "attachment": [], "flagged": false, "summary": "Android: Backing out of root window with exitOnClose false shows splash if child window closed programmatically", "creator": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "environment": null, "closedSprints": [ { "id": 1058, "state": "closed", "name": "2018 Sprint 16 SDK", "startDate": "2018-07-29T22:26:06.486Z", "endDate": "2018-08-12T22:26:00.000Z", "completeDate": "2018-08-13T17:38:16.757Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "439216", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "I can validate the issue in Android 8.1.0 device with SDK 7.2.0.GA. I was able to reproduce the behavior described. Moving to engineering.", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2018-07-15T17:12:08.000+0000", "updated": "2018-07-15T17:12:08.000+0000" }, { "id": "439242", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This is not a bug. This is the correct behavior.\r\nThe root activity is the splashscreen. That root activity also hosts Titanium's JavaScript runtime.\r\n\r\nThe 1st window you create in Titanium is actually the 2nd activity that gets created and is a child activity window on top of the activity hosting the splashscreen image. When {{exitOnClose}} is set to {{true}} (the default) on the 1st window you create, Titanium will automatically close the root splashscreen activity when your 1st window is closed. Setting it to {{false}} prevents this behavior and the Android OS will navigate back to the root splash activity.\r\n\r\nIf you want the app to be backgrounded instead, then you should override the back button and do a home button equivalent like the below. This effectively makes your app behave like iOS and prevents it from closing.\r\n{code:javascript}\r\nvar window = Ti.UI.createWindow();\r\nwindow.addEventListener(\"androidback\", function(e) {\r\n\t// If the back key was press, cancel it and go to the home-screen instead.\r\n\tvar intent = Ti.Android.createIntent({\r\n\t\taction: Ti.Android.ACTION_MAIN,\r\n\t});\r\n\tintent.addCategory(Ti.Android.CATEGORY_HOME);\r\n\tintent.setFlags(Ti.Android.FLAG_ACTIVITY_NEW_TASK);\r\n\tTi.Android.currentActivity.startActivity(intent);\r\n});\r\nwindow.open();\r\n{code}\r\n\r\nDoes this help?", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-07-16T18:07:49.000+0000", "updated": "2018-07-16T18:07:49.000+0000" }, { "id": "439243", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "But why does this only happen, when you close the 2nd window with the `homeAsUp` button and not when you just close the button with the back button? It's not consistent that it will go to the splash screen. It actually goes to background when you open the app and click the system back arrow and won't show the splashscreen (the first try in the video).\r\n\r\n-I've tested the intent version before but I think it had a different bug. I'll test that again!-\r\nThe intent version looks correct in the demo app. I'll check it inside the full app to see where the problem was. Might be some implementation ", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-07-16T18:30:59.000+0000", "updated": "2018-07-16T18:44:51.000+0000" }, { "id": "439245", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I'm not sure what you mean. The {{displayHomeAsUp}} is an Android feature intended to go to a root window of your choosing. It's not designed to take you to the Android OS home screen, although you can rig it to do that via the intent I showed you up above.\r\nhttps://developer.android.com/training/implementing-navigation/ancestral\r\n\r\nBut what I said is definitely true. The root activity window is the splash screen. This is what hosts your JS code. Once that root splash activity gets destroyed, it'll also terminate the JS runtime. So, they key to keep it running is to prevent it from being destroyed. And the only known way that I know of is to override the back key and do a home button press equivalent as I've shown you.", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-07-16T18:54:44.000+0000", "updated": "2018-07-16T18:54:44.000+0000" }, { "id": "439246", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hmm... looks like I wasn't fully aware of how are {{exitOnClose}} feature completely works. Sorry about that. Yes, this does look like a bug.\r\n\r\nOur {{exitOnClose}} supports 2 bits of functionality when set {{false}}:\r\n# If you call {{Window.close()}}, it will close the window (correct behavior) and takes you back to the root splash screen window instead of exiting the app. _(This is the feature I mentioned above.)_\r\n# If you press the Back button, it'll background the app instead of closing the window. _(I wasn't aware of this feature.)_\r\n\r\nThe 2 behaviors I've mentioned above can be seen with the following code.\r\n{code:javascript}\r\nvar window = Ti.UI.createWindow({ exitOnClose: false });\r\nvar closeButton = Ti.UI.createButton({ title: \"Close Child Window\" });\r\ncloseButton.addEventListener(\"click\", function(e) {\r\n\twindow.close();\r\n});\r\nwindow.add(closeButton);\r\nwindow.open();\r\n{code}\r\n\r\nThe issue you've mentioned happens when calling a 2nd window's {{close()}} method which can be reproduced with the below...\r\n{code:javascript}\r\nvar window = Ti.UI.createWindow({ exitOnClose: false });\r\nvar openButton = Ti.UI.createButton({ title: \"Open Child Window\" });\r\nopenButton.addEventListener(\"click\", function(e) {\r\n\tvar childWindow = Ti.UI.createWindow();\r\n\tvar closeButton = Ti.UI.createButton({ title: \"Close Child Window\" });\r\n\tcloseButton.addEventListener(\"click\", function(e) {\r\n\t\tchildWindow.close();\r\n\t});\r\n\tchildWindow.add(closeButton);\r\n\tchildWindow.open();\r\n});\r\nwindow.add(openButton);\r\nwindow.open();\r\n{code}\r\n\r\nI suspect this is an issue with our {{TiBaseActivity.onBackPressed()}} method looking at the top-most activity's proxy settings instead of its own.\r\nhttps://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/TiBaseActivity.java#L843\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-07-16T20:12:05.000+0000", "updated": "2018-07-16T20:12:05.000+0000" }, { "id": "439811", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Is this related to TIMOB-26269?", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-08-06T09:50:43.000+0000", "updated": "2018-08-06T09:50:43.000+0000" }, { "id": "440512", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~hknoechel], no. This ticket is a different issue. The issue here is if you programmatically close a child window, then \"exitiOnClose\" set to {{false}} no longer works.\r\n\r\n_Edit: Actually, let me double check with the other person in [TIMOB-26269]. I may be misinterpreting the issue he's running into._", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-08-06T18:01:46.000+0000", "updated": "2018-08-06T18:19:19.000+0000" }, { "id": "440523", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~michael], I can't reproduce this issue anymore with our latest changes to \"master\" and \"7_3_X\" branches. It looks like [~gmathews] has inadvertently fixed this with his changes to the window/memory handling here...\r\nhttps://github.com/appcelerator/titanium_mobile/commit/4a76b6f0922ffd90ea9628da174c99210b9c171a#diff-034a9360d01584987d9c951c0a215f65\r\n\r\nWe were missing a {{removeWindowFromStack()}} call in our Activity's {{onDestroy()}} method, which would happen if we closed the activity programmatically. So, the issue was that our {{onBackPressed()}} code was picking up the destroyed child window proxy that was still in the stack instead of the root window's proxy and the child window proxy did not have the \"exitOnClose\" property set.\r\n\r\nI guess this means Gary gets 2 points on Slack, eh?\r\nDon't spend them point all in one place now. :)", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-08-06T23:05:37.000+0000", "updated": "2018-08-06T23:05:37.000+0000" }, { "id": "440524", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "*Side Note:*\r\nI've confirmed that this issue was introduced as of Titanium 6.0.4.", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-08-06T23:16:51.000+0000", "updated": "2018-08-06T23:16:51.000+0000" }, { "id": "440558", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "Awesome! Works fine here, too. 7.3.0 is a great version!", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-08-07T17:58:48.000+0000", "updated": "2018-08-07T17:58:48.000+0000" }, { "id": "440594", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified works with SDK 7.3.0.v20180807095741 & 7.2.1.v20180726150551.\r\n\r\nClosing.", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-08-08T21:36:02.000+0000", "updated": "2018-08-08T21:36:02.000+0000" } ], "maxResults": 11, "total": 11, "startAt": 0 } } }