{ "id": "61674", "key": "TIMOB-1042", "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": "11224", "name": "Release 1.4.0", "archived": true, "released": true, "releaseDate": "2010-07-16" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T01:55:02.000+0000", "created": "2011-04-15T02:42:18.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "httpclient", "iphone" ], "versions": [], "issuelinks": [], "assignee": { "name": "rseagraves", "key": "rseagraves", "displayName": "Reggie Seagraves", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-04-17T01:55:02.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": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "{html}

My code is accessing a web service which compresses a large file\nthen sends it over the wire gzipped. It takes about 20 seconds for\nthe web service to reply. More often than not, the download fails\nwhen running on 1.3 (it works fine on 1.2.0). It seems the first\nfew packets come in (ondatachange is called a few times), then an\nexception is raised. Timeout on the connection is set to 2 minutes,\nwell above the time it takes to fail.

\n

I ran the program in a debugger and got the following\nbacktrace:

\n
\n#0  0x9738e4e6 in objc_exception_throw ()\n#1  0x02a04c3b in +[NSException raise:format:arguments:] ()\n#2  0x02a04b9a in +[NSException raise:format:] ()\n#3  0x004aecc9 in _NSArrayRaiseBoundException ()\n#4  0x0044c2e5 in -[NSCFArray insertObject:atIndex:] ()\n#5  0x0044c284 in -[NSCFArray addObject:] ()\n#6  0x00035a3a in -[KrollBridge registerProxy:] (self=0x5322c00,\n_cmd=0x91e26897, proxy=0x5374be0) at\n/Users/ema/Desktop/mobanki/Anki/build/iphone/Classes/KrollBridge.mm:455\n#7  0x0008690b in -[TiProxy _initWithPageContext:] (self=0x5374be0,\n_cmd=0x296ac0, context=0x5322c00) at\n/Users/ema/Desktop/mobanki/Anki/build/iphone/Classes/TiProxy.m:208\n#8  0x00089e0d in -[TiNetworkHTTPClientResultProxy initWithDelegate:]\n(self=0x5374be0, _cmd=0x9729fe90, proxy=0x50316d0) at\n/Users/ema/Desktop/mobanki/Anki/build/iphone/Classes/TiNetworkHTTPClientResultProxy.m:34\n#9  0x0008c2ed in -[TiNetworkHTTPClientProxy setProgress:upload:]\n(self=0x50316d0, _cmd=0x28e84d, value=0.0317440554, upload=0 '\\000')\nat /Users/ema/Desktop/mobanki/Anki/build/iphone/Classes/TiNetworkHTTPClientProxy.m:443\n#10 0x029c072d in __invoking___ ()\n#11 0x029c0618 in -[NSInvocation invoke] ()\n#12 0x029e5158 in -[NSInvocation invokeWithTarget:] ()\n#13 0x0000fb6c in +[ASIHTTPRequest\nsetProgress:forProgressIndicator:upload:] (self=0x2e1c00,\n_cmd=0x28f216, progress=0.031744055987380317, indicator=0x50316d0,\nupload=0 '\\000') at\n/Users/ema/Desktop/mobanki/Anki/build/iphone/Classes/ASI/ASIHTTPRequest.m:1285\n#14 0x0000f711 in -[ASIHTTPRequest updateDownloadProgress]\n(self=0x5031950, _cmd=0x28d587) at\n/Users/ema/Desktop/mobanki/Anki/build/iphone/Classes/ASI/ASIHTTPRequest.m:1226\n#15 0x0000e884 in -[ASIHTTPRequest updateProgressIndicators]\n(self=0x5031950, _cmd=0x28d5fb) at\n/Users/ema/Desktop/mobanki/Anki/build/iphone/Classes/ASI/ASIHTTPRequest.m:1024\n#16 0x0000def9 in -[ASIHTTPRequest loadRequest] (self=0x5031950,\n_cmd=0x28d65a) at\n/Users/ema/Desktop/mobanki/Anki/build/iphone/Classes/ASI/ASIHTTPRequest.m:915\n#17 0x0000b79f in -[ASIHTTPRequest main] (self=0x5031950,\n_cmd=0x9736ec8e) at\n/Users/ema/Desktop/mobanki/Anki/build/iphone/Classes/ASI/ASIHTTPRequest.m:516\n#18 0x004bdb25 in -[NSOperation start] ()\n#19 0x00450f7d in -[NSThread main] ()\n#20 0x00450b18 in __NSThread__main__ ()\n#21 0x92a7ba19 in _pthread_start ()\n#22 0x92a7b89e in thread_start ()\nCurrent language:  auto; currently objective-c\n
{html}", "attachment": [ { "id": "17915", "filename": "shot.png", "author": { "name": "damienelmes", "key": "damienelmes", "displayName": "Damien Elmes", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:42:19.000+0000", "size": 418989, "mimeType": "image/png" } ], "flagged": false, "summary": "Regression in HTTPClient/1.3", "creator": { "name": "damienelmes", "key": "damienelmes", "displayName": "Damien Elmes", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "damienelmes", "key": "damienelmes", "displayName": "Damien Elmes", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "124650", "author": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "body": "{html}

would it be possible to get the URL to your gzip for testing? If\nnot, that's fine - just give me more details about the size so i\ncan try and re-create. thanks

{html}", "updateAuthor": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:42:19.000+0000", "updated": "2011-04-15T02:42:19.000+0000" }, { "id": "124651", "author": { "name": "damienelmes", "key": "damienelmes", "displayName": "Damien Elmes", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Here's the code to reproduce it:

\n
\nvar debug = Ti.API.debug;\n\nvar file = Titanium.Filesystem.getFile(\n    Titanium.Filesystem.applicationSupportDirectory + \"/tmp.file\");\n\n// work around the bug where onload events are sometimes not delivered\nvar utils = {};\nutils.clearXhrTimer = function () {\n    if (utils.currentXhrTimer) {\n        clearInterval(utils.currentXhrTimer);\n        utils.currentXhrTimer = null;\n    }\n};\n\n// a 6MB file to demonstrate the problem\nvar url = \"http://ankisrs.net/tmp/\";\n\nvar xhr;\nfunction downloadFile() {\n    xhr = Titanium.Network.createHTTPClient();\n    xhr.setTimeout(60000);\n    xhr.onerror = function(e) {\n        utils.clearXhrTimer();\n        alert(\"Error: \" + e.error);\n    };\n    xhr.onload = function() {\n        debug(xhr.status);\n        try {\n            utils.clearXhrTimer();\n            if (xhr.status == 200) {\n                if (file.exists()) {\n                    file.deleteFile();\n                }\n                file.write(this.responseData);\n                downloadFile();\n            }\n        } catch (err) {\n            alert (err);\n        }\n    };\n    xhr.ondatastream = function (e) {\n        debug(e.progress);\n    };\n    utils.clearXhrTimer();\n    utils.currentXhrTimer = setInterval(\n        function () {}, 1000);\n    xhr.open('POST', url);\n    xhr.send();\n}\n\ndownloadFile();\n
{html}", "updateAuthor": { "name": "damienelmes", "key": "damienelmes", "displayName": "Damien Elmes", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:42:19.000+0000", "updated": "2011-04-15T02:42:19.000+0000" }, { "id": "124652", "author": { "name": "damienelmes", "key": "damienelmes", "displayName": "Damien Elmes", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

(it's actually 40MB of random data zipped this time, but same\nproblem)

{html}", "updateAuthor": { "name": "damienelmes", "key": "damienelmes", "displayName": "Damien Elmes", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:42:19.000+0000", "updated": "2011-04-15T02:42:19.000+0000" }, { "id": "124653", "author": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "body": "{html}

OK, i'll take a look at this ASAP.

{html}", "updateAuthor": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:42:19.000+0000", "updated": "2011-04-15T02:42:19.000+0000" }, { "id": "124654", "author": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "body": "{html}

tried 5-6 times to reproduce ... seems to work all the time. no\ncrashes...

\n

can you possibly try building and testing from head?

{html}", "updateAuthor": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:42:20.000+0000", "updated": "2011-04-15T02:42:20.000+0000" }, { "id": "124655", "author": { "name": "damienelmes", "key": "damienelmes", "displayName": "Damien Elmes", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Compiled from head - at first I thought I'd done something wrong\nas you've made the build process much faster! I'm assuming the\nversion # is supposed to be 1.3.1?

\n

Unfortunately the problem is still there. I discovered that I'd\nset the delay to 2 seconds during testing. I was still able to\nreproduce it with that short delay, but I've set it back to 20\nseconds now in case it's a timing issue. Could you give it another\ngo?

\n

I also tried creating a new project and copying the code above\ninto app.js (deleting the default stuff), and still got the\nproblem.

{html}", "updateAuthor": { "name": "damienelmes", "key": "damienelmes", "displayName": "Damien Elmes", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:42:20.000+0000", "updated": "2011-04-15T02:42:20.000+0000" }, { "id": "124656", "author": { "name": "damienelmes", "key": "damienelmes", "displayName": "Damien Elmes", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Did some more testing. I can reproduce this every time when\nrunning from the simulator, but was unable to reproduce this even\none when running on a device. If I comment out the ondatastream\nfunction, the error doesn't occur either. I guess it's a race\ncondition?

{html}", "updateAuthor": { "name": "damienelmes", "key": "damienelmes", "displayName": "Damien Elmes", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:42:20.000+0000", "updated": "2011-04-15T02:42:20.000+0000" }, { "id": "124657", "author": { "name": "damienelmes", "key": "damienelmes", "displayName": "Damien Elmes", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

I've been trying to squeeze a bit more performance out of\nHTTPClient - download speeds are about 3x slower on a device than\nin the simulator, both running of the wireless network. Perhaps I'm\njust being unrealistic about what a 2nd gen touch can do. I have a\n1st gen touch which is much slower again, but it's been acting\nfunny recently, so I'm not sure if its poor performance is due to a\nhardware fault or not.

\n

Anyway, I wrote a patch to reduce the frequency the progress\nhandlers were called, in the hope that would speed things up. I\nended up reverting it because it had a negligible impact on\ndownload speed, but one nice side effect it had was to stop this\nproblem from popping up. I mention it in case that makes it any\neasier to debug. OTOH, since this doesn't seem to appear outside\nthe simulator, it's not a big deal.

\n

\nhttp://github.com/dae/titanium_mobile/commit/f6a50354b4f6987d903576...

{html}", "updateAuthor": { "name": "damienelmes", "key": "damienelmes", "displayName": "Damien Elmes", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:42:20.000+0000", "updated": "2011-04-15T02:42:20.000+0000" }, { "id": "124658", "author": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "body": "{html}

can you try with the latest from master?
\ni've updated to the latest ASIHTTPRequest which seems to have some\nperformance improvements.

{html}", "updateAuthor": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:42:20.000+0000", "updated": "2011-04-15T02:42:20.000+0000" }, { "id": "124659", "author": { "name": "damienelmes", "key": "damienelmes", "displayName": "Damien Elmes", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

The latest ASI has fixed the download issue I was seeing in the\nemulator (and I saw it happen once on a real device, but only\nonce), so you can mark this issue as closed now. Thanks for the\nfix!

{html}", "updateAuthor": { "name": "damienelmes", "key": "damienelmes", "displayName": "Damien Elmes", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:42:20.000+0000", "updated": "2011-04-15T02:42:20.000+0000" } ], "maxResults": 10, "total": 10, "startAt": 0 } } }