{ "id": "173043", "key": "TIMOB-26850", "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": "19882", "name": "Release 8.0.0", "archived": false, "released": true, "releaseDate": "2019-03-14" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2019-03-04T10:21:38.000+0000", "created": "2019-02-22T17:09:58.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "activity", "android", "callback", "qe-testadded", "regression" ], "versions": [ { "id": "20238", "description": "", "name": "Release 7.5.0", "archived": false, "released": true, "releaseDate": "2018-11-15" } ], "issuelinks": [], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2019-04-30T22:41:02.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\nIf \"tiapp.xml\" property \"run-on-main-thread\" is set to {{true}}, then the activity's {{onStop}} and {{onDestroy}} callbacks are not invoked upon app exit. This is a regression as of 7.5.0.\r\n\r\n*Steps to reproduce:*\r\n# Set \"tiapp.xml\" property \"run-on-main-thread\" to {{true}} as shown below.\r\n# Use the below \"app.js\" code.\r\n# Build and run on Android.\r\n# Wait for the app to launch.\r\n# Notice in the log that \"onStart()\" and \"onResume()\" were successfully called.\r\n# Back out of the app to exit.\r\n# Notice in the log that \"TopActivity.onStop()\", \"TopActivity.onDestroy()\", and \"RootActivity.onDesroy()\" did *+not+* get called.\r\n\r\n*tiapp.xml*\r\n{code:xml}\r\n\r\n\r\n\ttrue\r\n\r\n{code}\r\n\r\n*app.js*\r\n{code:javascript}\r\nfunction addActivityListenersTo(activity, name) {\r\n\tif (!activity) {\r\n\t\treturn;\r\n\t}\r\n\tif (!name) {\r\n\t\tname = \"Activity\";\r\n\t}\r\n\tactivity.onCreate = function() {\r\n\t\tTi.API.info(\"@@@ \" + name + \".onCreate() called.\");\r\n\t};\r\n\tactivity.onRestart = function() {\r\n\t\tTi.API.info(\"@@@ \" + name + \".onRestart() called.\");\r\n\t};\r\n\tactivity.onStart = function() {\r\n\t\tTi.API.info(\"@@@ \" + name + \".onStart() called.\");\r\n\t};\r\n\tactivity.onResume = function() {\r\n\t\tTi.API.info(\"@@@ \" + name + \".onResume() called.\");\r\n\t};\r\n\tactivity.onPause = function() {\r\n\t\tTi.API.info(\"@@@ \" + name + \".onPause() called.\");\r\n\t};\r\n\tactivity.onStop = function() {\r\n\t\tTi.API.info(\"@@@ \" + name + \".onStop() called.\");\r\n\t};\r\n\tactivity.onDestroy = function() {\r\n\t\tTi.API.info(\"@@@ \" + name + \".onDestroy() called.\");\r\n\t};\r\n}\r\n\r\naddActivityListenersTo(Ti.Android.currentActivity, \"RootActivity\");\r\n\r\nvar window = Ti.UI.createWindow();\r\nwindow.add(Ti.UI.createLabel({ text: \"Activity Callback Test\" }));\r\nwindow.addEventListener(\"open\", function() {\r\n\tTi.API.info(\"@@@ Window 'open' event fired.\");\r\n});\r\naddActivityListenersTo(window.activity, \"TopActivity\");\r\nwindow.open();\r\n{code}\r\n\r\n*Work-Around 1:*\r\nIf you are building with Titanium 7.5.x, then setting \"run-on-main-thread\" to {{false}} then the {{onStop()}} and {{onDestroy()}} callbacks will be successfully invoked.\r\n\r\n*Work-Around 2:*\r\nAdd a listener to the {{Ti.UI.Window}} object's \"close\" event instead. This event is supported on both Android and iOS, making it a portable solution.\r\n", "attachment": [], "flagged": false, "summary": " Android: Activity callbacks onStop/onDestroy not invoked on main thread as of 7.5.0", "creator": { "name": "aislam", "key": "aislam", "displayName": "Aminul Islam", "active": false, "timeZone": "Etc/GMT-6" }, "subtasks": [], "reporter": { "name": "aislam", "key": "aislam", "displayName": "Aminul Islam", "active": false, "timeZone": "Etc/GMT-6" }, "environment": "Operating System\r\n Name = Mac OS X\r\n Version = 10.13.4\r\n Architecture = 64bit\r\n # CPUs = 4\r\n Memory = 8589934592\r\nNode.js\r\n Node.js Version = 10.14.1\r\n npm Version = 6.8.0\r\nTitanium CLI\r\n CLI Version = 5.1.1\r\nTitanium SDK\r\n SDK Version = 7.5.0.GA", "closedSprints": [ { "id": 1118, "state": "closed", "name": "2019 Sprint 5", "startDate": "2019-02-24T18:36:06.435Z", "endDate": "2019-03-08T18:36:00.000Z", "completeDate": "2019-03-07T22:19:47.057Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "446381", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR (master): https://github.com/appcelerator/titanium_mobile/pull/10733\r\nPR (8.0.x): https://github.com/appcelerator/titanium_mobile/pull/10734\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-02-28T00:36:28.000+0000", "updated": "2019-02-28T00:36:28.000+0000" }, { "id": "446414", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I see. Then an alternative solution that will work *+today+* is to use the {{Ti.UI.Window}} \"focus\" and \"blur\" events. These events will be fired in the same manner as {{onStop}} and {{onStart}}. And these events are definitely not fired when displaying an alert or tapping on a {{TextField}}. You can test out these events with my code below.\r\nhttps://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Window-event-focus\r\nhttps://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Window-event-blur\r\n{code:javascript}\r\nvar window = Ti.UI.createWindow({\r\n\tlayout: \"vertical\",\r\n\tfullscreen: true,\r\n});\r\nvar alertButton = Ti.UI.createButton({\r\n\ttitle: \"Show Alert\",\r\n\ttop: \"20%\",\r\n});\r\nalertButton.addEventListener(\"click\", function(e) {\r\n\t// An alert dialog does not trigger window focus/blur events.\r\n\talert(\"Alert!\");\r\n});\r\nwindow.add(alertButton);\r\nvar windowButton = Ti.UI.createButton({\r\n\ttitle: \"Show Child Window\",\r\n\ttop: \"20%\",\r\n});\r\nwindowButton.addEventListener(\"click\", function(e) {\r\n\t// Displaying a child window does trigger parent window's focus/blur events.\r\n\tvar childWindow = Ti.UI.createWindow({ backgroundColor: \"orange\" });\r\n\tvar closeButton = Ti.UI.createButton({ title: \"Close Me\" });\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(windowButton);\r\nwindow.addEventListener(\"focus\", function(e) {\r\n\tTi.API.info(\"@@@ Window 'focus' event received.\");\r\n});\r\nwindow.addEventListener(\"blur\", function(e) {\r\n\tTi.API.info(\"@@@ Window 'blur' event received.\");\r\n});\r\nwindow.open();\r\n{code}\r\n\r\n\r\nWe also have a {{Ti.App}} \"userinteraction\" event that we've added to 7.5.0 that was intended to be used by apps that want to implement an auto-logout feature. This event will be fired any time the end-user taps on the app's screen or enters input. The idea is that you would reset a timer every time a \"userinteraction\" event is received, but if the timer elapses, then go ahead and trigger the auto-logout.\r\nhttps://docs.appcelerator.com/platform/latest/#!/api/Titanium.App-event-userinteraction\r\n\r\nAlso note that in Titanium 8.0.1, we plan on modifying Android's {{Ti.App}} \"pause\" and \"resume\" events to match iOS' behavior. Where the \"pause\" event is fired when the app is put into the background and the \"resume\" event happens when the app is put into the foreground. This would mean that you no longer have to track Android activities anymore.\r\nSee: [TIMOB-26746]\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-02-28T19:30:13.000+0000", "updated": "2019-02-28T20:04:32.000+0000" }, { "id": "446426", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "FR Passed.\r\nWaiting for Merge to be enabled.", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-02-28T22:20:02.000+0000", "updated": "2019-02-28T22:20:02.000+0000" }, { "id": "446462", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR's merged.", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-03-01T22:51:16.000+0000", "updated": "2019-03-01T22:51:16.000+0000" }, { "id": "446479", "author": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket, fix verified in SDK Version 8.1.0.v20190301155716 and SDK Version 8.0.0.v20190301145350.\r\n\r\nTest and other information can be found at: \r\nPR (master): https://github.com/appcelerator/titanium_mobile/pull/10733\r\nPR (8.0.x): https://github.com/appcelerator/titanium_mobile/pull/10734", "updateAuthor": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-03-04T10:21:34.000+0000", "updated": "2019-03-04T10:21:34.000+0000" } ], "maxResults": 14, "total": 14, "startAt": 0 } } }