{ "id": "167395", "key": "TIMOB-24648", "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-05-22T12:50:49.000+0000", "created": "2017-05-01T20:36:25.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "network" ], "versions": [], "issuelinks": [], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2017-05-23T12:09:09.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": "Network activity indicator only works for the first network call. Subsequent network calls do not show the network activity indicator. I traced this through xcode and it looks like synchronous requests are calling TiApp stopNetwork twice.\r\n\r\nIn TiNetworkHTTPClientProxy:\r\nin send\r\n\r\n{code:java}\r\n[[TiApp app] startNetwork];\r\n if(async) {\r\n [httpRequest setTheQueue:operationQueue];\r\n [httpRequest send];\r\n } else {\r\n [httpRequest setSynchronous:YES];\r\n [httpRequest send];\r\n NSLog(@\"Calling Stop Network from sync\");\r\n [[TiApp app] stopNetwork];\r\n [self forgetSelf];\r\n }\r\n{code}\r\nIn request onLoad..\r\n\r\n{code:java}\r\n-(void)request:(APSHTTPRequest *)request onLoad:(APSHTTPResponse *)response\r\n{\r\n NSLog(@\"Calling Stop Network from request onLoad\");\r\n [[TiApp app] stopNetwork];\r\n if([request cancelled]) {\r\n [self forgetSelf];\r\n return;\r\n }\r\n NSInteger responseCode = [response status];\r\n /**\r\n * Per customer request, successful communications that resulted in an\r\n * 4xx or 5xx response is treated as an error instead of an onload.\r\n * For backwards compatibility, if no error handler is provided, even\r\n * an 4xx or 5xx response will fall back onto an onload.\r\n */\r\n if (hasOnerror && (responseCode >= 400) && (responseCode <= 599)) {\r\n NSMutableDictionary * event = [TiUtils dictionaryWithCode:responseCode message:@\"HTTP error\"];\r\n [event setObject:@\"error\" forKey:@\"type\"];\r\n [self fireCallback:@\"onerror\" withArg:event withSource:self withHandler:^(id result){\r\n [self forgetSelf];\r\n }];\r\n } else if(hasOnload) {\r\n NSMutableDictionary * event = [TiUtils dictionaryWithCode:0 message:nil];\r\n [event setObject:@\"load\" forKey:@\"type\"];\r\n [self fireCallback:@\"onload\" withArg:event withSource:self withHandler:^(id result){\r\n [self forgetSelf];\r\n }];\r\n } else {\r\n [self forgetSelf];\r\n }\r\n}\r\n{code}\r\n\r\nMy Log from a one synchronous request\r\n\r\n{code:java}\r\n2017-05-01 16:19:16.658 My App[98152:872410] Start Network\r\n2017-05-01 16:19:16.867 My App[98152:872651] Calling Stop Network from request onLoad\r\n2017-05-01 16:19:16.868 My App[98152:872410] Stop Network\r\n2017-05-01 16:19:16.868 My App[98152:872651] Calling Stop Network from sync\r\n2017-05-01 16:19:16.868 My App[98152:872410] Stop Network\r\n{code}\r\n\r\n", "attachment": [], "flagged": false, "summary": "iOS: Network Activity Indicator does not work for Synchronous Requests", "creator": { "name": "nthurston8", "key": "nthurston8", "displayName": "Nicholas Thurston", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "nthurston8", "key": "nthurston8", "displayName": "Nicholas Thurston", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "OSX 10.12.4\r\nAppcelerator Studio, build: 4.8.1\r\nTitanium SDK 6.0.4.GA\r\nXcode 8.3.2", "comment": { "comments": [ { "id": "418563", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, Can you share a reproducible code and steps to test the issue in our environment? Thanks.", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-05-02T14:16:46.000+0000", "updated": "2017-05-02T14:16:46.000+0000" }, { "id": "418581", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "PR: https://github.com/appcelerator/titanium_mobile/pull/9006\r\n\r\nTest-Case (Sync-Request with 2sec delay to see the loader):\r\n{code:js}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: '#fff'\r\n});\r\n\r\nvar btn = Ti.UI.createButton({\r\n title: 'Trigger'\r\n});\r\n\r\nbtn.addEventListener('click', function() {\r\n var url = \"https://httpbin.org/delay/2\";\r\n var client = Ti.Network.createHTTPClient({\r\n // function called when the response data is available\r\n onload : function(e) {\r\n Ti.API.info(\"Received text: \" + this.responseText);\r\n alert('success');\r\n },\r\n // function called when an error occurs, including a timeout\r\n onerror : function(e) {\r\n Ti.API.debug(e.error);\r\n alert('error');\r\n },\r\n async: false,\r\n timeout : 15000 // in milliseconds\r\n });\r\n // Prepare the connection.\r\n client.open(\"GET\", url);\r\n // Send the request.\r\n client.send();\r\n});\r\n\r\nwin.add(btn);\r\nwin.open();\r\n{code}", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-05-02T16:08:01.000+0000", "updated": "2017-05-02T16:08:01.000+0000" }, { "id": "420205", "author": { "name": "htbryant", "key": "htbryant", "displayName": "Harry Bryant", "active": true, "timeZone": "Europe/London" }, "updateAuthor": { "name": "htbryant", "key": "htbryant", "displayName": "Harry Bryant", "active": true, "timeZone": "Europe/London" }, "created": "2017-05-23T12:08:45.000+0000", "updated": "2017-05-23T12:08:45.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }