{ "id": "159164", "key": "TIMOB-23222", "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": "17707", "name": "Release 5.3.0", "archived": false, "released": true, "releaseDate": "2016-06-04" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2016-04-18T22:43:15.000+0000", "created": "2016-03-31T06:46:21.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [], "versions": [ { "id": "17707", "name": "Release 5.3.0", "archived": false, "released": true, "releaseDate": "2016-06-04" } ], "issuelinks": [], "assignee": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-31T22:05:11.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 makes the app crash in the for-loop.\r\nWhen decreasing the number of loops to run the risk of getting the crash decreases. (i<200 often works, but i<2048 crashes most of the time).\r\n\r\n{code}\r\nvar file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, \"data/data.bin\");\r\n\r\nTi.API.info('File meta:' + file.size);\r\nvar blob = file.read();\r\nvar length = blob.length;\r\n\r\n// Convert Ti.Blob to Ti.Buffer\r\nvar stream = Ti.Stream.createStream({source:blob, mode: Ti.Stream.MODE_READ});\r\nvar buffer = Ti.createBuffer({length: length});\r\nstream.read(buffer);\r\nTi.API.info(\"file loaded. size=\"+buffer.length);\r\n\r\n// Read and parse the data\r\nvar index = Ti.Codec.decodeNumber({source:buffer, position:0, type:Ti.Codec.TYPE_INT});\r\nTi.API.info('Checkpoint:');\r\nvar myArray = [];\r\nfor (var i=0; i<2048; i++) {\r\n myArray.push([\r\n Ti.Codec.decodeNumber({source:buffer, position:4+i*8+0, type:Ti.Codec.TYPE_INT}),\r\n Ti.Codec.decodeNumber({source:buffer, position:4+i*8+4, type:Ti.Codec.TYPE_INT})\r\n ]);\r\n};\r\nTi.API.info('Done');\r\n{code}\r\n", "attachment": [ { "id": "58775", "filename": "data.bin", "author": { "name": "jonasbjurhult", "key": "jonasbjurhult", "displayName": "Jonas Bjurhult", "active": true, "timeZone": "Europe/Stockholm" }, "created": "2016-03-31T06:34:31.000+0000", "size": 4303394, "mimeType": "application/macbinary" } ], "flagged": false, "summary": "Windows: Ti.Codec.decodeNumber crashes when reading from buffer", "creator": { "name": "jonasbjurhult", "key": "jonasbjurhult", "displayName": "Jonas Bjurhult", "active": true, "timeZone": "Europe/Stockholm" }, "subtasks": [], "reporter": { "name": "jonasbjurhult", "key": "jonasbjurhult", "displayName": "Jonas Bjurhult", "active": true, "timeZone": "Europe/Stockholm" }, "environment": "Crashes on Windows emulator XDE\r\nWorks on Android and iOS.\r\n\r\nsdk-version 5.4.0.v20160301084038", "closedSprints": [ { "id": 618, "state": "closed", "name": "2016 Sprint 08 SDK", "startDate": "2016-04-09T00:30:18.262Z", "endDate": "2016-04-23T00:30:00.000Z", "completeDate": "2016-04-25T02:38:28.511Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "381162", "author": { "name": "nsalahin", "key": "nsalahin", "displayName": "Nazmus Salahin", "active": true, "timeZone": "Asia/Dhaka" }, "body": "Hello,\r\nThis might be a memory issue in your windows phone or emulator. I am not able to reproduce this issue exactly as you described but got similar kind of result. In my case executing the given code does not lead to app crash but it takes a lot of time to fulfill the task on windows while on android it takes very little amount of time. \r\n\r\n*Steps:*\r\n1. Create a default classic project for windows and android.\r\n2. Create a function in app.js and insert given code in that function.\r\n3. Call the function. I did call the function on button click in my code.\r\n4. Build and run the app on windows phone.\r\n5. On executing the function the following console log in produced immediately.\r\n{code}\r\n[INFO] : File meta:4303394\r\n[INFO] : file loaded. size=4303394\r\n[INFO] : Checkpoint:\r\n{code}\r\n6. On Windows, the following log comes after over a minute but on android it takes a second or two.\r\n{code}\r\n[INFO] : Done\r\n{code}\r\n*Code:*\r\n{code}\r\nvar win = Titanium.UI.createWindow({\r\n\ttitle : 'Test Window',\r\n\tbackgroundColor : '#000'\r\n});\r\n\r\nvar button = Titanium.UI.createButton({\r\n title: 'Run Function',\r\n top: 10,\r\n width: 100,\r\n height: 50\r\n});\r\nbutton.addEventListener('click',function(e)\r\n{\r\n codeGiven();\r\n});\r\n\r\nwin.add(button);\r\n\r\nwin.open();\r\n\r\nvar codeGiven = function() {\r\n\tvar file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, \"data/data.bin\");\r\n\r\n\tTi.API.info('File meta:' + file.size);\r\n\r\n\tvar blob = file.read();\r\n\r\n\tvar length = blob.length;\r\n\r\n\t// Convert Ti.Blob to Ti.Buffer\r\n\r\n\tvar stream = Ti.Stream.createStream({\r\n\t\tsource : blob,\r\n\t\tmode : Ti.Stream.MODE_READ\r\n\t});\r\n\r\n\tvar buffer = Ti.createBuffer({\r\n\t\tlength : length\r\n\t});\r\n\r\n\tstream.read(buffer);\r\n\r\n\tTi.API.info(\"file loaded. size=\" + buffer.length);\r\n\r\n\t// Read and parse the data\r\n\r\n\tvar index = Ti.Codec.decodeNumber({\r\n\t\tsource : buffer,\r\n\t\tposition : 0,\r\n\t\ttype : Ti.Codec.TYPE_INT\r\n\t});\r\n\r\n\tTi.API.info('Checkpoint:');\r\n\r\n\tvar myArray = [];\r\n\r\n\tfor (var i = 0; i < 4096; i++) {\r\n\r\n\t\tmyArray.push([Ti.Codec.decodeNumber({\r\n\t\t\tsource : buffer,\r\n\t\t\tposition : 4 + i * 8 + 0,\r\n\t\t\ttype : Ti.Codec.TYPE_INT\r\n\t\t}), Ti.Codec.decodeNumber({\r\n\t\t\tsource : buffer,\r\n\t\t\tposition : 4 + i * 8 + 4,\r\n\t\t\ttype : Ti.Codec.TYPE_INT\r\n\t\t})]);\r\n\r\n\t};\r\n\r\n\tTi.API.info('Done');\r\n\r\n\treturn;\r\n};\r\n\r\n\r\n\r\n{code}\r\n\r\n*Environment*:\r\n\r\n*Device info:* Nexux7 (android 6.0.1), Windows Phone 8.1\r\n*Node.js Version:* 0.12.7\r\n*npm Version:* 2.11.3\r\n*Titanium SDKs:* 5.2.1.GA, 5.2.0.GA and 5.2.1.GA\r\n*Java Development Kit Version:* 1.8.0_73\r\n*Titanium CLI Version:* 5.0.5\r\n*Appcelerator CLI Version:* 5.2.0\r\n*Appcelerator Studio:* 4.4.0.201511241829", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2016-03-31T10:26:14.000+0000", "updated": "2016-04-01T19:39:40.000+0000" }, { "id": "381699", "author": { "name": "buder", "key": "buder", "displayName": "Jörgen Buder", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hi\r\n\r\nAs stated above the code does not run in the SDK: sdk-version 5.4.0.v20160301084038, you are testing the code in your GA branches, now since the 5.3.0 is coming out with Windows main fokus it is critical that it does work there before release, can you please test this on the SDK mentioned above to just verify that we indeed have the same problem AND then test to see if this works for you in the 5.3.0 latest that will be released... I will try to do the same but have no time as of right now..", "updateAuthor": { "name": "buder", "key": "buder", "displayName": "Jörgen Buder", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-04-05T06:33:07.000+0000", "updated": "2016-04-05T06:33:07.000+0000" }, { "id": "382854", "author": { "name": "buder", "key": "buder", "displayName": "Jörgen Buder", "active": true, "timeZone": "Europe/Berlin" }, "body": "Any new comment in this regarding the above comment from me?\r\n\r\nI am now looking into this again and I have constant crashes when trying to decodeNumber from the stream, specifically when it has been iterating, I am using the above SDK so please run that. My code on Windows is speedy and have no issues to run fast... but it crashes...\r\n\r\nI am looking into the SDK native code for the moment but have not been able to debug it, is there a way to make prints in the SDK so I can debug the code when building for the emulator?\r\n\r\nAlso how would I rebuild the SDK if I do some fixes?\r\n\r\nThis is a critical fix for your windows release next week, please get back to us.\r\n\r\nThanks", "updateAuthor": { "name": "buder", "key": "buder", "displayName": "Jörgen Buder", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-04-15T18:56:13.000+0000", "updated": "2016-04-15T18:56:13.000+0000" }, { "id": "382855", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, \r\n\r\nThanks for your concern. We also have observed similar behavior in our platform. Moving this ticket to engineering, for them to work on. You can follow the link here for building your own SDK. http://docs.appcelerator.com/platform/latest/#!/guide/Building_the_Titanium_SDK_From_Source\r\n\r\nRegards,\r\nSharif", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2016-04-15T19:35:25.000+0000", "updated": "2016-04-15T19:35:25.000+0000" }, { "id": "382940", "author": { "name": "buder", "key": "buder", "displayName": "Jörgen Buder", "active": true, "timeZone": "Europe/Berlin" }, "body": "Does not seem to apply for building the Windows Titanium SDK, or at least all I find is how to build the Ti SDK for Android and iOS.. am I wrong?", "updateAuthor": { "name": "buder", "key": "buder", "displayName": "Jörgen Buder", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-04-18T07:05:28.000+0000", "updated": "2016-04-18T07:05:28.000+0000" }, { "id": "382949", "author": { "name": "buder", "key": "buder", "displayName": "Jörgen Buder", "active": true, "timeZone": "Europe/Berlin" }, "body": "Observation from here:\r\n\r\nI had huge problems running the code for 512 iterations but on my system I had it running in maybe 5 sec in total so it was not slow (Windows phone 8.1 emulator, on device I can see nothing due to no loggs). If I split the loop up in smaller chunks, like 64 iteration each and them separating them in time they all run without crash, this implies some sort of memory issue, I had a look at the native code and there seem to be a sync task in there, even though there is a wait state I am thinking maybe that is the core problem, that it cannot do it in the async task... let me know if you need any help, test or feedback as I can run updates really quickly over here and help you test it and see if it works.\r\n\r\nI have also had problems (after initiating the first iteration of 512, even if they work in chunks) to access only one decodeNumber, as it crashes immiditakey concurrently efter that..\r\n\r\nThanks for your attention", "updateAuthor": { "name": "buder", "key": "buder", "displayName": "Jörgen Buder", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-04-18T07:37:25.000+0000", "updated": "2016-04-18T07:37:25.000+0000" }, { "id": "382972", "author": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "body": "https://github.com/appcelerator/titanium_mobile_windows/pull/631", "updateAuthor": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2016-04-18T13:07:42.000+0000", "updated": "2016-04-18T13:07:42.000+0000" }, { "id": "383032", "author": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Merged to master. I expect this will be available on today's nightly build.", "updateAuthor": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2016-04-18T23:04:48.000+0000", "updated": "2016-04-18T23:04:48.000+0000" }, { "id": "383487", "author": { "name": "buder", "key": "buder", "displayName": "Jörgen Buder", "active": true, "timeZone": "Europe/Berlin" }, "body": "Just tested this in the 5.4.0.v20160420 nitghly build, and I cannot still iterate 512 times calling the decode number, it crashes on my set up using that SDK and Windows Phone SDK 8.1, with Visual 2013.\r\n\r\nTargeting Phone 8.1\r\n\r\nPlease help, is the fix NOT in that build?", "updateAuthor": { "name": "buder", "key": "buder", "displayName": "Jörgen Buder", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-04-21T08:07:59.000+0000", "updated": "2016-04-21T08:07:59.000+0000" }, { "id": "383521", "author": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "body": "I confirmed test program doesn't crash on {{5.4.0.v20160420120113}}. So basic issue for this is all about the memory consumption at runtime. My fix was just to reduce memory consumption at decodeNumber but still crash could happen due to memory consumption overall in other areas at runtime... Is there any areas possible to reduce memory? I guess Ti.Codec could have reduce more too so I'll look into it.\r\n\r\n", "updateAuthor": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2016-04-21T10:52:09.000+0000", "updated": "2016-04-21T10:52:09.000+0000" }, { "id": "383645", "author": { "name": "buder", "key": "buder", "displayName": "Jörgen Buder", "active": true, "timeZone": "Europe/Berlin" }, "body": "I will try to confirm this my self but I had a total crash using that SDK (second that day right) my app would just not start at all so I could not verify the decodeNumber, but what you are saying is that that SDK version is the first one where the decodeNumber improvments where integrated correct? ", "updateAuthor": { "name": "buder", "key": "buder", "displayName": "Jörgen Buder", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-04-22T07:49:55.000+0000", "updated": "2016-04-22T07:49:55.000+0000" }, { "id": "386694", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "[~kota] This fix is present in the latest 5.3.0 build 5.3.0.v20160523083840 could the fixVersion be amended to reflect this? Thanks!", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2016-05-24T22:40:39.000+0000", "updated": "2016-05-24T22:40:39.000+0000" }, { "id": "416563", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as fixed, if there are any problems, please file a new ticket.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-31T22:05:11.000+0000", "updated": "2017-03-31T22:05:11.000+0000" } ], "maxResults": 14, "total": 14, "startAt": 0 } } }