{ "id": "151886", "key": "AC-1220", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2015-10-22T05:22:31.000+0000", "created": "2015-10-09T09:40:00.000+0000", "labels": [ "ios", "ipad", "iphone" ], "versions": [], "issuelinks": [ { "id": "49413", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "outwardIssue": { "id": "152241", "key": "TIMOB-19760", "fields": { "summary": "iOS: Enabled main thread produces unexpected behavior", "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" } }, "priority": { "name": "Critical", "id": "1" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "49411", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "152241", "key": "TIMOB-19760", "fields": { "summary": "iOS: Enabled main thread produces unexpected behavior", "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" } }, "priority": { "name": "Critical", "id": "1" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "rtlechuga", "key": "rtlechuga", "displayName": "Radamantis Torres-Lechuga", "active": false, "timeZone": "Asia/Dubai" }, "updated": "2016-03-08T07:37:36.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": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "{code:title=Environment}\r\nOperating System\r\n Name = Mac OS X\r\n Version = 10.11\r\n Architecture = 64bit\r\n # CPUs = 8\r\n Memory = 17179869184\r\n\r\nNode.js\r\n Node.js Version = 0.10.38\r\n npm Version = 1.4.28\r\n\r\nTitanium CLI\r\n CLI Version = 4.1.5\r\n\r\nTitanium SDK\r\n SDK Version = 5.0.2.GA / 5.2.0.v20151008212033\r\n SDK Path = /Volumes/Data/Users/sebastian/Library/Application Support/Titanium/mobilesdk/osx/5.2.0.v20151008212033\r\n Target Platform = iphone\r\n{code}\r\n\r\nI found a behaviour in the newest SDKs which are not reproducible but good comparable with the actual GA SDK. I made two videos for better visualization.\r\n\r\nThe same behaviour exists, when I call a function instead of the \"self eventlistener\".\r\n\r\n5.0.2.GA\r\nhttp://cl.ly/image/0A2v2D1E0i3P\r\n\r\n5.2.0.v20151008212033\r\nhttp://cl.ly/image/1j2M2S1M1f3w\r\n\r\n{code:title=Test app}\r\nvar refreshBtn = Ti.UI.createButton({\r\n systemButton: Ti.UI.iPhone.SystemButton.REFRESH\r\n});\r\n\r\n// creating the window\r\nvar self = Ti.UI.createWindow({\r\n title: 'event test',\r\n backgroundColor: '#fff',\r\n rightNavButton: refreshBtn\r\n});\r\n\r\nrefreshBtn.addEventListener('click', function () {\r\n self.fireEvent('refreshList', {});\r\n});\r\n\r\nvar navController = Ti.UI.iOS.createNavigationWindow({\r\n window: self\r\n});\r\n\r\n// the progressbar I expect to see\r\nvar progressLoadingBar = Ti.UI.createProgressBar({\r\n width: '80%',\r\n color: '#000',\r\n font: {\r\n fontSize: 14\r\n },\r\n min: 0,\r\n max: 0,\r\n value: 0\r\n});\r\nself.add(progressLoadingBar);\r\n\r\nvar listViewItemsCount = 10000, itemsArray = [];\r\n\r\nvar listView = Ti.UI.createListView({});\r\n\r\n// showing the listView\r\nself.addEventListener('refreshList', function () {\r\n\r\n //Hide listView to show indicator\r\n listView.hide();\r\n\r\n // resetting the progressBar\r\n progressLoadingBar.setValue(0);\r\n progressLoadingBar.setMax(listViewItemsCount);\r\n\r\n // show the progressbar\r\n progressLoadingBar.show();\r\n\r\n var section = Ti.UI.createListSection({});\r\n\r\n // adding the items\r\n for (var i = 1; i < listViewItemsCount; i++) {\r\n itemsArray.push({\r\n properties: {\r\n itemId: i,\r\n title: 'Item ' + i,\r\n subtitle: 'Subtitle for item ' + i\r\n },\r\n template: Ti.UI.LIST_ITEM_TEMPLATE_SUBTITLE\r\n });\r\n progressLoadingBar.setValue(i);\r\n }\r\n\r\n section.setItems(itemsArray);\r\n listView.setSections([section]);\r\n\r\n // show the listview\r\n listView.show();\r\n\r\n // hide the progressbar\r\n progressLoadingBar.hide();\r\n});\r\n\r\n// listen to the event\r\nself.fireEvent('refreshList', {});\r\n\r\nnavController.open();\r\n{code}", "attachment": [ { "id": "56951", "filename": "5.0.2_Example.gif", "author": { "name": "benutzername", "key": "benutzername", "displayName": "Sebastian Klaus", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-10-09T09:38:56.000+0000", "size": 569002, "mimeType": "image/gif" }, { "id": "56950", "filename": "5.2.x_Example.gif", "author": { "name": "benutzername", "key": "benutzername", "displayName": "Sebastian Klaus", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-10-09T09:39:23.000+0000", "size": 610457, "mimeType": "image/gif" } ], "flagged": false, "summary": "Abnormal event and function handling in SDK 5.1.x and 5.2.x", "creator": { "name": "benutzername", "key": "benutzername", "displayName": "Sebastian Klaus", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "benutzername", "key": "benutzername", "displayName": "Sebastian Klaus", "active": true, "timeZone": "Europe/Berlin" }, "environment": null, "comment": { "comments": [ { "id": "366909", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "There's a lot of different parts to the test case you provided. You say _The same behaviour exists, when I call a function instead of the \"self eventlistener\"._. Could you try to minimalist the use case so it's more precise, easier to track and quicker to fix?", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-10-15T09:01:17.000+0000", "updated": "2015-10-15T09:01:17.000+0000" }, { "id": "366911", "author": { "name": "benutzername", "key": "benutzername", "displayName": "Sebastian Klaus", "active": true, "timeZone": "Europe/Berlin" }, "body": "It seems, that the code within a eventListener or a function will be completely executed and after finishing all work, the view actions are executed.\r\n\r\nAs an example: I have a loading window with a progressbar for an export function. I start the export, nothing happens (no overlay with progressbar is shown). then, after doing all databse operations and file writings, the overlay flashes short with a progressbar 100% filled.\r\n\r\nThe example code show the problem. All code excepting the code which is responsible for the views is executed one by one. The code, which is responsible for the views, seems to be executed at the end and all of my commands at the same time.\r\n\r\nI hope, I described it more clearly now. ", "updateAuthor": { "name": "benutzername", "key": "benutzername", "displayName": "Sebastian Klaus", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-10-15T09:08:37.000+0000", "updated": "2015-10-15T09:09:25.000+0000" }, { "id": "366912", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "[~cng] [~penrique] can this be a side effect of TIMOB-18976 which is now default in SDK 5.1? (TIMOB-19682)", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-10-15T09:11:07.000+0000", "updated": "2015-10-15T09:11:07.000+0000" }, { "id": "366914", "author": { "name": "benutzername", "key": "benutzername", "displayName": "Sebastian Klaus", "active": true, "timeZone": "Europe/Berlin" }, "body": "I just tested to set the this.runOnMainThread = false in the iphone/cli/commands/_build.py\r\n\r\nThis has no effect building with 5.2.0.v20151014151229\r\n\r\nBut I don't really know if this would be the only change I have to do. Was just trying out.", "updateAuthor": { "name": "benutzername", "key": "benutzername", "displayName": "Sebastian Klaus", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-10-15T09:30:11.000+0000", "updated": "2015-10-15T09:30:42.000+0000" }, { "id": "367010", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Please try disabling it for testing purposes using the tiapp.xml:\r\n\r\n{code}\r\n\r\n false\r\n ...\r\n\r\n{code}\r\n\r\nThat will disable it inside the SDK itself. I didn't thought about Fokke's idea, but is really seems like the only thing that changed and might effect this behavior. Give it a try!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-10-16T17:50:55.000+0000", "updated": "2015-10-16T17:53:20.000+0000" }, { "id": "367014", "author": { "name": "benutzername", "key": "benutzername", "displayName": "Sebastian Klaus", "active": true, "timeZone": "Europe/Berlin" }, "body": "Yes, that did it. \r\nBut of course I want to use with runOnMainThread = true. It's a huge performance difference.\r\n\r\nDo you have any code example how I can figure out that?", "updateAuthor": { "name": "benutzername", "key": "benutzername", "displayName": "Sebastian Klaus", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-10-16T18:05:33.000+0000", "updated": "2015-10-16T18:05:33.000+0000" }, { "id": "367503", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "[~benutzername] With the JS engine being on the main thread, you no longer have async UI updates. You will need to change your code to workaround this. This means splitting up workloads.\r\n\r\nSay you have an array of 100 items and for each item you want to do some work on it and update a progress bar. You will need to change your code so that the one unit of work is done in a recursive function that continually calls itself until all items are processed. The trick is you need to wrap nested calls in a {{setTimeout()}}. {{setTimeout()}} will cause the JS engine to schedule a continuation on the next tick and gives the UI a chance to update and events to be handled.", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2015-10-22T04:06:38.000+0000", "updated": "2015-10-22T04:06:38.000+0000" }, { "id": "368368", "author": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Verified fixed, using:\r\n\r\nMacOS 10.11.2 (15C27e)\r\nStudio 4.4.0.201510280736\r\nTi SDK 5.1.0.v20151028190028\r\nAppc NPM 4.2.1\r\nAppc CLI 5.1.0-38\r\nTi CLI 5.0.5\r\nAlloy 1.7.16\r\nArrow 1.3.13\r\nXcode 7.2 (7C46l)\r\nNode v0.12.7\r\nJava 1.7.0_80\r\nproduction\r\n\r\nUsed the sample code provided to test. Progress bar is shown as expected, on load, due to not running on the main thread, by default.", "updateAuthor": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2015-10-29T23:15:49.000+0000", "updated": "2015-10-29T23:15:49.000+0000" } ], "maxResults": 14, "total": 14, "startAt": 0 } } }