{ "id": "83321", "key": "AC-2729", "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": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2011-12-05T04:15:18.000+0000", "created": "2011-12-01T21:42:48.000+0000", "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "updated": "2016-03-08T07:47:37.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": "setInterval function is not working correctly. It is losing time. In common language, if a watch counts 30 sec it is counting 29 sec. Attached project will demonstrate same. \r\n\r\nYou can not replicate this in iOS simulator - this will happen only in devices.\r\n\r\nThe timer function is extremely important for my project.", "attachment": [ { "id": "24438", "filename": "timer.zip", "author": { "name": "sumitk", "key": "sumitk", "displayName": "Sumit Kataria", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-12-01T21:42:48.000+0000", "size": 536702, "mimeType": "application/zip" } ], "flagged": false, "summary": "iOS: setInterval loses 1 sec every 30 sec on certain devices", "creator": { "name": "sumitk", "key": "sumitk", "displayName": "Sumit Kataria", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "sumitk", "key": "sumitk", "displayName": "Sumit Kataria", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Using Titanium 1.7.1, 1.7.2 .... 1.7.6\r\n\r\nWorking correctly on:\r\n* iPhone 3GS + 4.3\r\n* iTouch4 + 4.1\r\n* iPhone simulator\r\n\r\nProblem exists on:\r\n* iPhone 4S + 5.0.1\r\n* iPhone 4 + 4.3\r\n* iPad2 & iPad1 + 4.3\r\n", "comment": { "comments": [ { "id": "174541", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Sumit\r\n\r\nThank you for raising this issue.\r\n\r\nYour code contains a lot of unnecessary code that could be influencing the behavior. Would you please write a test case, as described in [Creating a Test Case|http://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-CreatingaTestCase]? Also, test cases should be added to the body of the ticket rather than as an attachment, to make it easy for the engineering team to assess.\r\n\r\nOnce this is done, I will be able to move it across to the main project so that the engineering team can work on it.\r\n\r\nThanks", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-12-02T02:10:02.000+0000", "updated": "2011-12-02T02:10:02.000+0000" }, { "id": "174824", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "As kindly, and correctly, explained by JongEun, Javascript timers are not guaranteed.\r\n\r\n{code}\r\n> That's not a bug.\r\n> Javascript timer delay is not guranteed.\r\n> Becase Javascript excutes on a single thread.\r\n> Check this blog article\r\n> http://ejohn.org/blog/how-javascript-timers-work/\r\n>\r\n> You should not count in interval function :\r\n>\r\n> self.total_sec--;\r\n>\r\n>\r\n> how about this way?\r\n>\r\n> 1. when the timer start, save current Time\r\n>\r\n> 2. just caculate time and update view on interval timer function\r\n>\r\n> var startTime = new Date();\r\n>\r\n> setInterval(function(){\r\n>\r\n>\r\n> var timegap = new Date() - startTime;\r\n>\r\n> // do somthing (such as update view ....)\r\n>\r\n>\r\n> },1000);\r\n>\r\n>\r\n> CodeStrong!\r\n>\r\n>\r\n> JongEun.\r\n{code}\r\n\r\nThis solution should resolve this for you. Hence, marking this ticket as invalid.", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-12-05T04:14:59.000+0000", "updated": "2011-12-05T04:14:59.000+0000" }, { "id": "174953", "author": { "name": "sumitk", "key": "sumitk", "displayName": "Sumit Kataria", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Thanks Paul for referring this. \r\n\r\nYes above comment solved my blocker, but main issue is this is happening in a particular set of devices and others are behaving normally.", "updateAuthor": { "name": "sumitk", "key": "sumitk", "displayName": "Sumit Kataria", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-12-05T16:36:49.000+0000", "updated": "2011-12-05T16:36:49.000+0000" }, { "id": "174954", "author": { "name": "sumitk", "key": "sumitk", "displayName": "Sumit Kataria", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket", "updateAuthor": { "name": "sumitk", "key": "sumitk", "displayName": "Sumit Kataria", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-12-05T16:37:08.000+0000", "updated": "2011-12-05T16:37:08.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }