{ "id": "147278", "key": "TIMOB-18855", "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": "16723", "description": "Windows Platform Support, ListView updates, Vector overlays in maps", "name": "Release 4.1.0", "archived": false, "released": true, "releaseDate": "2015-07-08" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2015-05-04T14:19:19.000+0000", "created": "2015-04-25T17:29:14.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2015-07-13T21:14:04.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": "The following code demonstrates that when you create a {{new Date()}} object in a {{setTimeout}} or {{setInterval}} method the time is off by a factor 1000.\r\n\r\nIf you run https://github.com/appcelerator-developer-relations/Mobile-App-Performance/ you will see that this also occurs when you have a expensive computation that takes several seconds and you log the time before and after.\r\n\r\n{code}\r\nvar run = require('run');\r\n\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor: 'white',\r\n\tlayout: 'vertical'\r\n});\r\n\r\nvar btnTimeout = Ti.UI.createButton({\r\n\ttop: 20,\r\n\theight: 40,\r\n\tcolor: '#FFF',\r\n\tbackgroundColor: '#000',\r\n\ttitle: 'setTimeout'\r\n});\r\n\r\nbtnTimeout.addEventListener('click', function () {\r\n\taddLabel();\r\n\r\n\tsetTimeout(function () {\r\n\t\taddLabel();\r\n\r\n\t\tsetTimeout(function () {\r\n\t\t\taddLabel();\r\n\r\n\t\t\twin.add(btnInterval);\r\n\r\n\t\t}, 5000);\r\n\r\n\t}, 0);\r\n});\r\n\r\nwin.add(btnTimeout);\r\n\r\nvar btnInterval = Ti.UI.createButton({\r\n\ttop: 20,\r\n\theight: 40,\r\n\tcolor: '#FFF',\r\n\tbackgroundColor: '#000',\r\n\ttitle: 'setInterval'\r\n});\r\n\r\nbtnInterval.addEventListener('click', function () {\r\n\tvar interval;\r\n\tvar intervals = 0;\r\n\r\n\taddLabel();\r\n\r\n\tinterval = setInterval(function () {\r\n\r\n\t\tintervals++;\r\n\r\n\t\taddLabel();\r\n\r\n\t\tif (intervals === 2) {\r\n\t\t\tclearInterval(interval);\r\n\t\t}\r\n\r\n\t}, 5000);\r\n});\r\n\r\nfunction addLabel() {\r\n\tvar d = new Date();\r\n\r\n\twin.add(Ti.UI.createLabel({\r\n\t\ttop: 20,\r\n\t\twidth: Ti.UI.FILL,\r\n\t\theight: 40,\r\n\t\ttext: pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds()) + ':' + pad(d.getMilliseconds()),\r\n\t\tcolor: '#000'\r\n\t}));\r\n}\r\n\r\nfunction pad(int) {\r\n\tvar str = int.toString();\r\n\r\n\tif (str.length === 1) {\r\n\t\tstr = '0' + str;\r\n\t}\r\n\r\n\treturn str;\r\n}\r\n\r\nwin.open();\r\n{code}\r\n\r\nI did the tests on the Emulator, but looking at the results [~kota] achieved with https://github.com/appcelerator-developer-relations/Mobile-App-Performance/ the same is true for device.", "attachment": [ { "id": "55084", "filename": "iOS Simulator Screen Shot 25 Apr 2015 19.25.26.png", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-04-25T17:31:17.000+0000", "size": 41812, "mimeType": "image/png" }, { "id": "55085", "filename": "Screen Shot 2015-04-25 at 19.24.04.png", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-04-25T17:31:17.000+0000", "size": 101032, "mimeType": "image/png" } ], "flagged": false, "summary": "Windows: Time between creating Date() objects runs a factor 1000 slower then reality", "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": "Windows SDK 4.1.0.v20150423183637\r\nTitanium CLI 3.6.0-dev / 4.1.0-dev", "closedSprints": [ { "id": 394, "state": "closed", "name": "2015 Sprint 09 Windows", "startDate": "2015-04-26T05:00:09.221Z", "endDate": "2015-05-10T03:59:00.000Z", "completeDate": "2015-05-11T13:20:23.987Z", "originBoardId": 144 } ], "comment": { "comments": [ { "id": "350751", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Attached the results on iOS and Windows Emulator", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-04-25T17:31:17.000+0000", "updated": "2015-04-25T17:32:40.000+0000" }, { "id": "350834", "author": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Confirmed that this issue is Windows-specific which originally because JavaScriptCore evaluates wrong {{Date}}. Following test cases represents the issue, which is failing on Windows, which is passed on OS X.\r\n\r\n{code}\r\nTEST_F(JSContextTests, TIMOB_18855) {\r\n JSContext js_context = js_context_group.CreateContext();\r\n js_context.JSEvaluateScript(\"var start=new Date().getTime();\");\r\n std::this_thread::sleep_for(std::chrono::milliseconds(1000));\r\n JSValue js_value = js_context.JSEvaluateScript(\"new Date().getTime() - start;\");\r\n XCTAssertFalse(static_cast(js_value) == 1);\r\n XCTAssertTrue(static_cast(js_value) > 999);\r\n // assuming JS evaluation is done within 100 msec...\r\n XCTAssertTrue(static_cast(js_value) < 1100);\r\n}\r\n{code}", "updateAuthor": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2015-04-27T05:14:11.000+0000", "updated": "2015-04-27T05:14:11.000+0000" }, { "id": "350839", "author": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "body": "I suspect it is somewhat related to \"date time cache\" because first \"new Date()\" call returns valid value. Note that Ti Windows is based on nearly 2 years old JavaScriptCore and there are numerous changes since then, including date time calculation and cache. https://github.com/WebKit/webkit/commits/master/Source/JavaScriptCore/runtime/JSDateMath.cpp", "updateAuthor": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2015-04-27T07:28:44.000+0000", "updated": "2015-04-27T07:28:44.000+0000" }, { "id": "351127", "author": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "body": "I was able to fix this. It was a small bug originally introduced by Igalia: https://github.com/infosia/webkit-wp8/commit/e4d0d6034ba12c8b2ae9563836b078ace9d59fac The bad news is that I have been failing to build JavaScriptCore for ARM locally, maybe it is environmental issue. Do we have CI build server for JavaScriptCore?", "updateAuthor": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2015-04-29T11:31:33.000+0000", "updated": "2015-04-29T11:31:33.000+0000" }, { "id": "351224", "author": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "body": "https://github.com/appcelerator/HAL/pull/45", "updateAuthor": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2015-04-30T03:37:46.000+0000", "updated": "2015-04-30T03:37:46.000+0000" }, { "id": "351247", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "[~kota] is there a build available already that I can run the benchmarks on?", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-04-30T08:20:40.000+0000", "updated": "2015-04-30T08:20:40.000+0000" }, { "id": "351249", "author": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "body": "[~fokkezb] Yes, download latest JavaScriptCore [JavaScriptCore-Windows-1430359270.zip|http://timobile.appcelerator.com.s3.amazonaws.com/jscore/JavaScriptCore-Windows-1430359270.zip], and extract it to your JavaScriptCore_HOME. It's safe to overwrite existing *.lib there. Then clean and rebuild your benchmark app.", "updateAuthor": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2015-04-30T08:45:25.000+0000", "updated": "2015-04-30T08:45:25.000+0000" }, { "id": "357591", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "Verified using:\r\n\r\nWindows 8.1\r\nAppc CLI (NPM): 4.1.0\r\nAppc CLI (Registry): 4.1.0\r\nTi SDK: 4.1.0.GA\r\n\r\nUsing the provided sample code the results provided are expected and match the pattern of the iOS results\r\n\r\nClosing ticket", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2015-07-13T21:13:59.000+0000", "updated": "2015-07-13T21:13:59.000+0000" } ], "maxResults": 8, "total": 8, "startAt": 0 } } }