{ "id": "168606", "key": "TIMOB-24893", "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": "18414", "description": "", "name": "Release 6.2.0", "archived": false, "released": true, "releaseDate": "2017-09-13" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2017-08-25T12:40:42.000+0000", "created": "2017-06-26T14:15:52.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "regression" ], "versions": [ { "id": "18414", "description": "", "name": "Release 6.2.0", "archived": false, "released": true, "releaseDate": "2017-09-13" } ], "issuelinks": [ { "id": "55810", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "169418", "key": "TIMOB-25072", "fields": { "summary": "Windows: Liveview not working for windows application", "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": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2017-08-28T15:20:41.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": "12642", "name": "Windows", "description": "Windows authoring support" } ], "description": "h5.Description\r\n\r\n**The code below is a boiled down version of how LiveView makes http requests so it is crucial for this to work**\r\n\r\nThe following code below appears to freeze the application, I believe this is because HTTPClient is running things such as onreadystatechange on the UI thread which is being blocked by the while loop, the following diff appears to fix the issue but I am not sure whether the changes were required https://gist.github.com/ewanharris/f45cf4347759247a3965e02161342fde\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow(),\r\n btn = Ti.UI.createButton({\r\n title: 'HTTP GET'\r\n });\r\nbtn.addEventListener('click', function () {\r\n var request = Ti.Network.createHTTPClient({\r\n onload: function () {\r\n alert('onload:\\n\\treadyState: ' + request.readyState);\r\n },\r\n onerror: function (e) {\r\n alert('onerror:\\n\\treadyState: ' + request.readyState + '\\n\\terror: ' + e.error);\r\n }\r\n }),\r\n timeout = new Date().getTime() + 5000,\r\n host = 'http://www.google.com/',\r\n done = false;\r\n request.cache = false;\r\n request.open('GET', host);\r\n request.send();\r\n while (!done) {\r\n if (request.readyState === 4 || request.status === 404) {\r\n done = true;\r\n alert('success');\r\n } else if ((timeout - (new Date()).getTime()) <= 0) {\r\n done = true;\r\n alert('failed');\r\n }\r\n }\r\n});\r\nwin.add(btn);\r\nwin.open();\r\n\r\n{code}\r\n\r\nh5.Steps to reproduce\r\n\r\n# Add the above code to an existing app.js and build for Windows\r\n# Click the HTTP GET button\r\n\r\nh5.Actual\r\n\r\nApp appears to freeze (button stays in clicked position), failed alert appears\r\n\r\nh5.Expected\r\n\r\nApp should not appear to freeze, no failed alert should show", "attachment": [], "flagged": false, "summary": "Windows: onreadystatechange should not be called on the UI thread", "creator": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "subtasks": [], "reporter": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "environment": "Ti SDK: 6.2.0.v20170623140932\r\nAppc CLI: 6.2.2\r\nAppc NPM: 4.2.9\r\nNokia Lumia 550\r\nWindows 10 Mobile emulator 10.0.14393\r\nWindows 10 Pro 10.0.15063\r\n", "closedSprints": [ { "id": 939, "state": "closed", "name": "2017 Sprint 17 SDK", "startDate": "2017-08-13T23:08:29.095Z", "endDate": "2017-08-27T23:08:00.000Z", "completeDate": "2017-08-27T21:10:54.125Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "424873", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "Assigning this to 6.2.0 as it is a regression and breaks liveview", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2017-07-27T10:15:56.000+0000", "updated": "2017-07-27T10:15:56.000+0000" }, { "id": "426516", "author": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Basically we need to ensure all JavaScript callbacks including {{onload}} and {{onerror}} should be called from UI thread especially on Windows 10 Store app, otherwise the app will crash. That's what TIMOB-24671 originally meant. For instance even following simple app crashes when you don't use {{RunOnUIThread}}. I would think that waiting {{readyState}} in while loop was basically a bad idea, but for a quick workaround I would suggest just removing {{RunOnUIThread}} from {{onreadystate}} for now, and deprecate listening {{onreadystate}} event on Windows Store app?\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow(),\r\n btn = Ti.UI.createButton({\r\n title: 'HTTP GET'\r\n });\r\nbtn.addEventListener('click', function () {\r\n var request = Ti.Network.createHTTPClient({\r\n onload: function () {\r\n alert('onload:\\n\\treadyState: ' + request.readyState);\r\n },\r\n onerror: function (e) {\r\n alert('onerror:\\n\\treadyState: ' + request.readyState + '\\n\\terror: ' + e.error);\r\n }\r\n }),\r\n timeout = new Date().getTime() + 5000,\r\n host = 'http://www.theresnosuchdomain.com/',\r\n done = false;\r\n request.cache = false;\r\n request.open('GET', host);\r\n request.send();\r\n});\r\nwin.add(btn);\r\nwin.open();\r\n{code}", "updateAuthor": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-08-11T00:58:41.000+0000", "updated": "2017-08-11T01:07:30.000+0000" }, { "id": "426517", "author": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Can't we just update the LiveView to use {{setTimeout}} instead of waiting in while loop? We can use {{Ti.Platform.name == 'windows' }} to ensure this change affects only for Windows.\r\n\r\n{code}\r\n if (Ti.Platform.name == 'windows' ) {\r\n setTimeout(function () {\r\n if (request.readyState === 4 || request.status === 404) {\r\n alert('success');\r\n } else if ((timeout - (new Date()).getTime()) <= 0) {\r\n alert('failed');\r\n }\r\n }, timeout);\r\n }\r\n{code}", "updateAuthor": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-08-11T01:49:40.000+0000", "updated": "2017-08-11T01:49:40.000+0000" }, { "id": "426601", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "[~kiguchi] While I do agree that we could and should change LiveView I think we'd still need to revert the changes as we can't break usage in a minor. Also I'm not sure whether we're planning to release Studio alongside 6.2.0 which would be required if we made the changes in LiveView", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2017-08-14T09:40:26.000+0000", "updated": "2017-08-14T09:40:26.000+0000" }, { "id": "426673", "author": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "body": "https://github.com/appcelerator/titanium_mobile_windows/pull/1075", "updateAuthor": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-08-15T13:04:30.000+0000", "updated": "2017-08-15T13:04:30.000+0000" }, { "id": "427251", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "6_2_X backport: https://github.com/appcelerator/titanium_mobile_windows/pull/1086", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2017-08-25T12:39:59.000+0000", "updated": "2017-08-25T12:39:59.000+0000" }, { "id": "427303", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "Verified in 6.2.0.v20170825165823. Changes are not in master (7.0.0) yet though, will hold on closing til it is", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2017-08-28T10:58:47.000+0000", "updated": "2017-08-28T10:58:47.000+0000" }, { "id": "427309", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "Aaaand verified in 7.0.0.v20170828071347, closing ticket", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2017-08-28T15:20:34.000+0000", "updated": "2017-08-28T15:20:34.000+0000" } ], "maxResults": 10, "total": 10, "startAt": 0 } } }