{ "id": "119377", "key": "TIMOB-15105", "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": "15422", "description": "Release 3.3.0", "name": "Release 3.3.0", "archived": false, "released": true, "releaseDate": "2014-07-16" } ], "resolution": { "id": "2", "description": "The problem described is an issue which will never be fixed.", "name": "Won't Fix" }, "resolutiondate": "2014-04-14T21:24:17.000+0000", "created": "2013-09-03T08:52:03.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "android", "heavyweight", "open", "triage", "window" ], "versions": [ { "id": "15479", "description": "Release 3.1.2", "name": "Release 3.1.2", "archived": true, "released": true, "releaseDate": "2013-07-31" } ], "issuelinks": [], "assignee": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2014-05-08T06:35:24.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": "If opening a heavyweight window is followed by heavy operations, the window won't show until those computations are done.\r\n\r\n\r\nh1. Steps to reproduce\r\n# Execute the following code:\r\n {code}\r\n var red = Ti.UI.createWindow({backgroundColor:'red',modal:false});\r\n red.addEventListener('open', function () {\r\n Ti.API.debug('opened red');\r\n });\r\n Ti.API.debug('open red');\r\n red.open();\r\n\r\n var green = Ti.UI.createWindow({backgroundColor:'green',modal:false,layout:'vertical'});\r\n green.addEventListener('open', function () {\r\n Ti.API.debug('opened green');\r\n });\r\n\r\n for (var i = 0; i < 5000; i++) {\r\n green.add(Ti.UI.createView({backgroundColor:'blue',top:5,height:5}));\r\n }\r\n\r\n Ti.API.debug('open green');\r\n green.open();\r\n {code}\r\n# The console will say red opened a few seconds before green:\r\n {code}\r\n 10:34:43 [DEBUG] open red\r\n 10:34:46 [DEBUG] open green\r\n 10:34:46 [DEBUG] opened red\r\n 10:34:51 [DEBUG] opened green\r\n {code}\r\n# But on the device you won't see the red window at all.\r\n\r\n\r\nh1. Quick analysis\r\n\r\nLooking at the Titanium Android [WindowProxy|https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/WindowProxy.java#L294], line 294 I see that the open event is fired when the activity is created. So I guess this means it's not an Titanium bug but an Android one that actual showing the window is delayed by the heavy computation that follows.\r\n\r\n\r\nh1. Notes\r\n\r\n- When you change the red window to be lightweight it works fine.\r\n- When you wrap everything after line 6 in {{setTimeout}} statement it works fine.\r\n- When you replace adding the blue views by a non-UI/non-Proxy heavy computation, the problem stays the same.", "attachment": [], "flagged": false, "summary": "Android: Opening heavyweight window delayed by following heavy operations", "creator": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "subtasks": [], "reporter": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "environment": "SDK 3.1.2.GA\r\nAndroid 4.1.2 on Samsung Galaxy S2", "comment": { "comments": [ { "id": "270482", "author": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "body": "Hello,\n\non the side, this is the expected behavior since all those operations are running only in the UI thread. \n\nStill, moving to mobile, so the platform team can give us their opinion.\n\nBest,\n\nMauro ", "updateAuthor": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "created": "2013-09-09T23:21:14.000+0000", "updated": "2013-09-09T23:21:14.000+0000" }, { "id": "270647", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "It might explain it, but it's not what you'd want. And why then it doesn't happen on a lightweight window? And why does it fire {{open}} even if it clearly isn't? Not being able to depend on {{open}} being fired after actually having opened the window causes major problems if you want to act on the window following the event.", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2013-09-10T18:59:50.000+0000", "updated": "2013-09-10T18:59:50.000+0000" }, { "id": "275936", "author": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "body": "I've run into situations where the JS and native side get out of sync because of this behavior. Basically, JS processing continues, blocking/delaying the native side. You end up trying to access objects & properties that don't yet exist (on the native side) which causes your app to crash with a cryptic segfault error. Error reporting is minimal and confusing, and solutions to the situation are not obvious.", "updateAuthor": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "created": "2013-10-21T15:23:58.000+0000", "updated": "2013-10-21T15:23:58.000+0000" }, { "id": "278984", "author": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "body": "For HW windows, the \"open\" event is fired after the activity has been created and all the children views have been added, but before all the views are measured, laid out and rendered. That's why there is a delay between firing the \"open\" event and displaying all the views on the screen when 5000 views need to be measured, laid out and drawn.\n\nThe red window does not show before the green window opens is because after the activity for red window has been created, it immediately creates another new activity for green window. Therefore, Android puts the first activity (red window) on pause and decides not to draw this activity. This behavior can be confirmed in a native Android app.", "updateAuthor": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-11-11T19:25:13.000+0000", "updated": "2013-11-11T19:25:13.000+0000" }, { "id": "279082", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "[~pwang] thanks a lot for this clarification! Now, do you think we should consider postponing firing the {{open}} event until everything is layed out? Or maybe have another {{layout}} event that fires when this happend (and not every time the layout changes like {{postlayout}} does?)", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2013-11-12T08:28:18.000+0000", "updated": "2013-11-12T08:28:18.000+0000" }, { "id": "279675", "author": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "body": "It won't be a simple task to introduce a new event like that. We don't plan on resolving this for 3.2.0, but we'll definitely look into what is involved in introducing a new event that fires after all the views have been rendered.", "updateAuthor": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-11-14T23:56:43.000+0000", "updated": "2013-11-14T23:56:43.000+0000" }, { "id": "279937", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2013-11-16T12:57:40.000+0000", "updated": "2013-11-16T12:57:40.000+0000" }, { "id": "303974", "author": { "name": "nmittal", "key": "nmittal", "displayName": "Neha Mittal", "active": true, "timeZone": "Asia/Kolkata" }, "body": "Since this is won't fix. Hence closing the issue.", "updateAuthor": { "name": "nmittal", "key": "nmittal", "displayName": "Neha Mittal", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2014-05-08T06:35:24.000+0000", "updated": "2014-05-08T06:35:24.000+0000" } ], "maxResults": 9, "total": 9, "startAt": 0 } } }