{"action":"created","comment":{"url":"https://api.github.com/repos/smartdevicelink/sdl_ios/pulls/comments/109750411","pull_request_review_id":30785535,"id":109750411,"diff_hunk":"@@ -268,23 +304,9 @@ - (void)onSessionStreamsEnded:(SDLIAPSession *)session {\n #pragma mark - Data Transmission\n \n - (void)sendData:(NSData *)data {\n-    dispatch_async(_transmit_queue, ^{\n-        NSOutputStream *ostream = self.session.easession.outputStream;\n-        NSMutableData *remainder = data.mutableCopy;\n-\n-        while (ostream.streamStatus == NSStreamStatusOpen && remainder.length != 0) {\n-            if (ostream.hasSpaceAvailable){\n-                NSInteger bytesWritten = [ostream write:remainder.bytes maxLength:remainder.length];\n-\n-                if (bytesWritten == -1) {\n-                    [SDLDebugTool logInfo:[NSString stringWithFormat:@\"Error: %@\", [ostream streamError]] withType:SDLDebugType_Transport_iAP toOutput:SDLDebugOutput_All];\n-                    break;\n-                }\n-\n-                [remainder replaceBytesInRange:NSMakeRange(0, bytesWritten) withBytes:NULL length:0];\n-            }\n-        }\n-    });\n+    if (self.session != nil && self.session.accessory.connected){","path":"SmartDeviceLink/SDLIAPTransport.m","position":163,"original_position":163,"commit_id":"8cd5c94862771b56c172be674e8b8022df0046d5","original_commit_id":"8cd5c94862771b56c172be674e8b8022df0046d5","user":{"login":"joeljfischer","id":1767063,"avatar_url":"https://avatars3.githubusercontent.com/u/1767063?v=3","gravatar_id":"","url":"https://api.github.com/users/joeljfischer","html_url":"https://github.com/joeljfischer","followers_url":"https://api.github.com/users/joeljfischer/followers","following_url":"https://api.github.com/users/joeljfischer/following{/other_user}","gists_url":"https://api.github.com/users/joeljfischer/gists{/gist_id}","starred_url":"https://api.github.com/users/joeljfischer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joeljfischer/subscriptions","organizations_url":"https://api.github.com/users/joeljfischer/orgs","repos_url":"https://api.github.com/users/joeljfischer/repos","events_url":"https://api.github.com/users/joeljfischer/events{/privacy}","received_events_url":"https://api.github.com/users/joeljfischer/received_events","type":"User","site_admin":false},"body":"This should flip and return if it fails. The `{` goes a space after the `)`","created_at":"2017-04-04T19:02:36Z","updated_at":"2017-04-04T19:28:38Z","html_url":"https://github.com/smartdevicelink/sdl_ios/pull/597#discussion_r109750411","pull_request_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/pulls/597","_links":{"self":{"href":"https://api.github.com/repos/smartdevicelink/sdl_ios/pulls/comments/109750411"},"html":{"href":"https://github.com/smartdevicelink/sdl_ios/pull/597#discussion_r109750411"},"pull_request":{"href":"https://api.github.com/repos/smartdevicelink/sdl_ios/pulls/597"}}},"pull_request":{"url":"https://api.github.com/repos/smartdevicelink/sdl_ios/pulls/597","id":113828589,"html_url":"https://github.com/smartdevicelink/sdl_ios/pull/597","diff_url":"https://github.com/smartdevicelink/sdl_ios/pull/597.diff","patch_url":"https://github.com/smartdevicelink/sdl_ios/pull/597.patch","issue_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/issues/597","number":597,"state":"open","locked":false,"title":"IAP transport read/writes on background thread","user":{"login":"davidswi","id":978602,"avatar_url":"https://avatars0.githubusercontent.com/u/978602?v=3","gravatar_id":"","url":"https://api.github.com/users/davidswi","html_url":"https://github.com/davidswi","followers_url":"https://api.github.com/users/davidswi/followers","following_url":"https://api.github.com/users/davidswi/following{/other_user}","gists_url":"https://api.github.com/users/davidswi/gists{/gist_id}","starred_url":"https://api.github.com/users/davidswi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidswi/subscriptions","organizations_url":"https://api.github.com/users/davidswi/orgs","repos_url":"https://api.github.com/users/davidswi/repos","events_url":"https://api.github.com/users/davidswi/events{/privacy}","received_events_url":"https://api.github.com/users/davidswi/received_events","type":"User","site_admin":false},"body":"Fixes #522, #424 \r\n\r\nThis PR is ready for review.\r\n\r\n### Risk\r\nThis PR makes no API changes.\r\n\r\n### Testing Plan\r\nWe performed manual testing with a number of internal SDL test apps and prototype headunit hardware, covering validation and verification of correct RPC and a variety of cold and warm connect/disconnect scenarios over BT and USB. We are adding automated testing to perform longhaul characterization of MTTF.\r\n\r\n### Summary\r\nThis PR moves all IAP transport reads and writes for the active data session to a background thread. Send buffers are enqueued from the IAPTransport sendData method to an internal FIFO managed by the IAPSession instance. They are dequeued and consumed by the background thread using an initial stream write to consume as much of the buffer as possible, and by scheduled writes using the delegate space available callback to consume the remainder as space is available, thereby minimizing CPU utilization and preserving battery life when the iOS device is unplugged. For plugged scenarios, battery charging should be faster due to the minimized CPU utilization.\r\n\r\nIn addition, race conditions caused by sending events to deallocating proxy objects have been fixed. Crashes and hangs due to these race conditions should now be reduced to rare occurrences.\r\n\r\n### Changelog\r\n##### Breaking Changes\r\n* No API breaking changes.\r\n\r\n##### Enhancements\r\n* Data session I/O is now in full compliance with Apple guidelines.\r\n\r\n##### Bug Fixes\r\n* All session output stream API calls are made on the scheduled thread, scheduled thread is no longer the main thread and polling is no longer used to minimize CPU impact.\r\n\r\n### Tasks Remaining:\r\nAdditional PRs for remaining sources of crashes and hangs in SDLIAPTransport will be created along with supporting issues.\r\n","created_at":"2017-04-02T18:20:44Z","updated_at":"2017-04-04T19:28:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"88abbb895ef6cf67541d2c5ee2bbab082114eb93","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/smartdevicelink/sdl_ios/milestones/6","html_url":"https://github.com/smartdevicelink/sdl_ios/milestone/6","labels_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/milestones/6/labels","id":1125678,"number":6,"title":"4.5.X","description":"","creator":{"login":"joeljfischer","id":1767063,"avatar_url":"https://avatars3.githubusercontent.com/u/1767063?v=3","gravatar_id":"","url":"https://api.github.com/users/joeljfischer","html_url":"https://github.com/joeljfischer","followers_url":"https://api.github.com/users/joeljfischer/followers","following_url":"https://api.github.com/users/joeljfischer/following{/other_user}","gists_url":"https://api.github.com/users/joeljfischer/gists{/gist_id}","starred_url":"https://api.github.com/users/joeljfischer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joeljfischer/subscriptions","organizations_url":"https://api.github.com/users/joeljfischer/orgs","repos_url":"https://api.github.com/users/joeljfischer/repos","events_url":"https://api.github.com/users/joeljfischer/events{/privacy}","received_events_url":"https://api.github.com/users/joeljfischer/received_events","type":"User","site_admin":false},"open_issues":18,"closed_issues":99,"state":"open","created_at":"2015-05-22T13:25:41Z","updated_at":"2017-04-04T13:56:40Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/pulls/597/commits","review_comments_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/pulls/597/comments","review_comment_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/pulls/comments{/number}","comments_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/issues/597/comments","statuses_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/statuses/8cd5c94862771b56c172be674e8b8022df0046d5","head":{"label":"davidswi:feature/issue_566","ref":"feature/issue_566","sha":"8cd5c94862771b56c172be674e8b8022df0046d5","user":{"login":"davidswi","id":978602,"avatar_url":"https://avatars0.githubusercontent.com/u/978602?v=3","gravatar_id":"","url":"https://api.github.com/users/davidswi","html_url":"https://github.com/davidswi","followers_url":"https://api.github.com/users/davidswi/followers","following_url":"https://api.github.com/users/davidswi/following{/other_user}","gists_url":"https://api.github.com/users/davidswi/gists{/gist_id}","starred_url":"https://api.github.com/users/davidswi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidswi/subscriptions","organizations_url":"https://api.github.com/users/davidswi/orgs","repos_url":"https://api.github.com/users/davidswi/repos","events_url":"https://api.github.com/users/davidswi/events{/privacy}","received_events_url":"https://api.github.com/users/davidswi/received_events","type":"User","site_admin":false},"repo":{"id":83731741,"name":"sdl_ios","full_name":"davidswi/sdl_ios","owner":{"login":"davidswi","id":978602,"avatar_url":"https://avatars0.githubusercontent.com/u/978602?v=3","gravatar_id":"","url":"https://api.github.com/users/davidswi","html_url":"https://github.com/davidswi","followers_url":"https://api.github.com/users/davidswi/followers","following_url":"https://api.github.com/users/davidswi/following{/other_user}","gists_url":"https://api.github.com/users/davidswi/gists{/gist_id}","starred_url":"https://api.github.com/users/davidswi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidswi/subscriptions","organizations_url":"https://api.github.com/users/davidswi/orgs","repos_url":"https://api.github.com/users/davidswi/repos","events_url":"https://api.github.com/users/davidswi/events{/privacy}","received_events_url":"https://api.github.com/users/davidswi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/davidswi/sdl_ios","description":"Get your app connected to the 🚙, make your users feel like a 🌟","fork":true,"url":"https://api.github.com/repos/davidswi/sdl_ios","forks_url":"https://api.github.com/repos/davidswi/sdl_ios/forks","keys_url":"https://api.github.com/repos/davidswi/sdl_ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/davidswi/sdl_ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/davidswi/sdl_ios/teams","hooks_url":"https://api.github.com/repos/davidswi/sdl_ios/hooks","issue_events_url":"https://api.github.com/repos/davidswi/sdl_ios/issues/events{/number}","events_url":"https://api.github.com/repos/davidswi/sdl_ios/events","assignees_url":"https://api.github.com/repos/davidswi/sdl_ios/assignees{/user}","branches_url":"https://api.github.com/repos/davidswi/sdl_ios/branches{/branch}","tags_url":"https://api.github.com/repos/davidswi/sdl_ios/tags","blobs_url":"https://api.github.com/repos/davidswi/sdl_ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/davidswi/sdl_ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/davidswi/sdl_ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/davidswi/sdl_ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/davidswi/sdl_ios/statuses/{sha}","languages_url":"https://api.github.com/repos/davidswi/sdl_ios/languages","stargazers_url":"https://api.github.com/repos/davidswi/sdl_ios/stargazers","contributors_url":"https://api.github.com/repos/davidswi/sdl_ios/contributors","subscribers_url":"https://api.github.com/repos/davidswi/sdl_ios/subscribers","subscription_url":"https://api.github.com/repos/davidswi/sdl_ios/subscription","commits_url":"https://api.github.com/repos/davidswi/sdl_ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/davidswi/sdl_ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/davidswi/sdl_ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/davidswi/sdl_ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/davidswi/sdl_ios/contents/{+path}","compare_url":"https://api.github.com/repos/davidswi/sdl_ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/davidswi/sdl_ios/merges","archive_url":"https://api.github.com/repos/davidswi/sdl_ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/davidswi/sdl_ios/downloads","issues_url":"https://api.github.com/repos/davidswi/sdl_ios/issues{/number}","pulls_url":"https://api.github.com/repos/davidswi/sdl_ios/pulls{/number}","milestones_url":"https://api.github.com/repos/davidswi/sdl_ios/milestones{/number}","notifications_url":"https://api.github.com/repos/davidswi/sdl_ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/davidswi/sdl_ios/labels{/name}","releases_url":"https://api.github.com/repos/davidswi/sdl_ios/releases{/id}","deployments_url":"https://api.github.com/repos/davidswi/sdl_ios/deployments","created_at":"2017-03-02T22:34:53Z","updated_at":"2017-03-02T22:34:56Z","pushed_at":"2017-04-02T18:44:57Z","git_url":"git://github.com/davidswi/sdl_ios.git","ssh_url":"git@github.com:davidswi/sdl_ios.git","clone_url":"https://github.com/davidswi/sdl_ios.git","svn_url":"https://github.com/davidswi/sdl_ios","homepage":"www.smartdevicelink.com","size":23868,"stargazers_count":0,"watchers_count":0,"language":"Objective-C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"smartdevicelink:master","ref":"master","sha":"b9cf970c7390f02cdea95773c571811d4aba78f0","user":{"login":"smartdevicelink","id":8671397,"avatar_url":"https://avatars0.githubusercontent.com/u/8671397?v=3","gravatar_id":"","url":"https://api.github.com/users/smartdevicelink","html_url":"https://github.com/smartdevicelink","followers_url":"https://api.github.com/users/smartdevicelink/followers","following_url":"https://api.github.com/users/smartdevicelink/following{/other_user}","gists_url":"https://api.github.com/users/smartdevicelink/gists{/gist_id}","starred_url":"https://api.github.com/users/smartdevicelink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smartdevicelink/subscriptions","organizations_url":"https://api.github.com/users/smartdevicelink/orgs","repos_url":"https://api.github.com/users/smartdevicelink/repos","events_url":"https://api.github.com/users/smartdevicelink/events{/privacy}","received_events_url":"https://api.github.com/users/smartdevicelink/received_events","type":"Organization","site_admin":false},"repo":{"id":24940582,"name":"sdl_ios","full_name":"smartdevicelink/sdl_ios","owner":{"login":"smartdevicelink","id":8671397,"avatar_url":"https://avatars0.githubusercontent.com/u/8671397?v=3","gravatar_id":"","url":"https://api.github.com/users/smartdevicelink","html_url":"https://github.com/smartdevicelink","followers_url":"https://api.github.com/users/smartdevicelink/followers","following_url":"https://api.github.com/users/smartdevicelink/following{/other_user}","gists_url":"https://api.github.com/users/smartdevicelink/gists{/gist_id}","starred_url":"https://api.github.com/users/smartdevicelink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smartdevicelink/subscriptions","organizations_url":"https://api.github.com/users/smartdevicelink/orgs","repos_url":"https://api.github.com/users/smartdevicelink/repos","events_url":"https://api.github.com/users/smartdevicelink/events{/privacy}","received_events_url":"https://api.github.com/users/smartdevicelink/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/smartdevicelink/sdl_ios","description":"Get your app connected to the 🚙, make your users feel like a 🌟","fork":false,"url":"https://api.github.com/repos/smartdevicelink/sdl_ios","forks_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/forks","keys_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/teams","hooks_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/hooks","issue_events_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/issues/events{/number}","events_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/events","assignees_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/assignees{/user}","branches_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/branches{/branch}","tags_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/tags","blobs_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/statuses/{sha}","languages_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/languages","stargazers_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/stargazers","contributors_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/contributors","subscribers_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/subscribers","subscription_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/subscription","commits_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/contents/{+path}","compare_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/merges","archive_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/downloads","issues_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/issues{/number}","pulls_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/pulls{/number}","milestones_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/milestones{/number}","notifications_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/labels{/name}","releases_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/releases{/id}","deployments_url":"https://api.github.com/repos/smartdevicelink/sdl_ios/deployments","created_at":"2014-10-08T12:57:22Z","updated_at":"2017-03-27T09:50:43Z","pushed_at":"2017-04-02T18:44:58Z","git_url":"git://github.com/smartdevicelink/sdl_ios.git","ssh_url":"git@github.com:smartdevicelink/sdl_ios.git","clone_url":"https://github.com/smartdevicelink/sdl_ios.git","svn_url":"https://github.com/smartdevicelink/sdl_ios","homepage":"www.smartdevicelink.com","size":24048,"stargazers_count":75,"watchers_count":75,"language":"Objective-C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":33,"mirror_url":null,"open_issues_count":52,"forks":33,"open_issues":52,"watchers":75,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/smartdevicelink/sdl_ios/pulls/597"},"html":{"href":"https://github.com/smartdevicelink/sdl_ios/pull/597"},"issue":{"href":"https://api.github.com/repos/smartdevicelink/sdl_ios/issues/597"},"comments":{"href":"https://api.github.com/repos/smartdevicelink/sdl_ios/issues/597/comments"},"review_comments":{"href":"https://api.github.com/repos/smartdevicelink/sdl_ios/pulls/597/comments"},"review_comment":{"href":"https://api.github.com/repos/smartdevicelink/sdl_ios/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/smartdevicelink/sdl_ios/pulls/597/commits"},"statuses":{"href":"https://api.github.com/repos/smartdevicelink/sdl_ios/statuses/8cd5c94862771b56c172be674e8b8022df0046d5"}}}}
{"actor":{"display_login":"joeljfischer"}}