{ "id": "171393", "key": "TIMOB-25901", "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": "20238", "description": "", "name": "Release 7.5.0", "archived": false, "released": true, "releaseDate": "2018-11-15" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2018-06-22T10:41:00.000+0000", "created": "2018-03-23T20:02:05.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "ios" ], "versions": [ { "id": "19906", "description": "", "name": "Release 6.3.0", "archived": false, "released": true, "releaseDate": "2017-11-01" }, { "id": "19957", "description": "", "name": "Release 7.1.0", "archived": false, "released": true, "releaseDate": "2018-03-14" } ], "issuelinks": [], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2018-10-18T10:51:41.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": "File TiApp.m\r\n\r\nApp crashes on line 632 \r\n\r\n/* for (id key in pendingCompletionHandlers) {\r\n [self completionHandler:key withResult:2]; //UIBackgroundFetchResultFailed\r\n } */\r\n\r\n// elements of array are removed while array is enumerated\r\n// YOU SHOULD TRY LIKE THIS:\r\n \r\n for (id key in [pendingCompletionHandlers allKeys]) {\r\n [self completionHandler:key withResult:2]; //UIBackgroundFetchResultFailed\r\n }", "attachment": [], "flagged": false, "summary": "iOS: App crashes when background services expire and queue tries to flush", "creator": { "name": "office@smartbit.rs", "key": "office@smartbit.rs", "displayName": "Igor Stojanovic", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "office@smartbit.rs", "key": "office@smartbit.rs", "displayName": "Igor Stojanovic", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "SDK 6+ (tested on 6.3, 7.0.1 and 7.1)", "comment": { "comments": [ { "id": "435882", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hey [~office@smartbit.rs], thanks for your report! What a stupid typo, sorry for that. We'll fix it right away and release it with the next patch.\r\n\r\n*EDIT*: Actually, I would like to propose a different change: Instead of looping through a mutable dictionary and remove keys during the iteration, I would rather mark the keys that should be called in a separate dictionary, call them and remove them from the original dictionary later. Does that make sense? I still wonder why this didn't surface before - maybe only in some cases where it's causing a race condition?", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-03-24T08:33:16.000+0000", "updated": "2018-03-24T14:51:01.000+0000" }, { "id": "435884", "author": { "name": "office@smartbit.rs", "key": "office@smartbit.rs", "displayName": "Igor Stojanovic", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hey Hans,\r\nAllKeys will create separated (new) Array with keys. \r\nAnd iteration in this case goes trough that array instead mutableDict.\r\n\r\nYour propose also could be good but it depend of object inside dict. Probably you can also remove original dictionary later but in that case for some time you will have objects inside array which can have maybe undefined state (I don't know full code...)\r\nE.g.\r\nloop\r\n completionHandler = [pendingCompletionHandlers objectForKey:key];\r\n completionHandler(result); // this is called for each object but object is still alive when loop is ended\r\nend loop\r\n// in this point we still have objects in Dict. but we called completionHandler(result); IS THAT DANGEROUS ?\r\n[pendingCompletionHandlers removeAllObjects];\r\n", "updateAuthor": { "name": "office@smartbit.rs", "key": "office@smartbit.rs", "displayName": "Igor Stojanovic", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-03-24T15:43:06.000+0000", "updated": "2018-03-24T15:43:06.000+0000" }, { "id": "435885", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "PR: https://github.com/appcelerator/titanium_mobile/pull/9957\r\n\r\nTest-Case: Follow [this guide|https://docs.appcelerator.com/platform/latest/#!/guide/iOS_Background_Services] and let the background-service expire.\r\n\r\n[~office@smartbit.rs] If you don't mind, I'd like to ask you to test this change as well. I decided to refactor a bit more and change the handler removal to an own guard (\"removeAfterExecution\") that is not called anymore, since the whole dictionary is cleared after the enumeration anyway. Thanks again for bringing this up!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-03-24T15:44:18.000+0000", "updated": "2018-03-24T15:44:18.000+0000" }, { "id": "436623", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~office@smartbit.rs] Have you been able to verify the changes on your end? Thanks!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-04-09T08:07:15.000+0000", "updated": "2018-04-09T08:07:15.000+0000" }, { "id": "436626", "author": { "name": "office@smartbit.rs", "key": "office@smartbit.rs", "displayName": "Igor Stojanovic", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi Hans,\r\nIt looks good to me...\r\nWe will schedule some time for test in to the company in next few weeks.\r\nThanks", "updateAuthor": { "name": "office@smartbit.rs", "key": "office@smartbit.rs", "displayName": "Igor Stojanovic", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-04-09T10:06:51.000+0000", "updated": "2018-04-09T10:06:51.000+0000" }, { "id": "438627", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~office@smartbit.rs] The PR was just merged. Let me know how your internal tests went for another opinion!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-06-22T10:41:33.000+0000", "updated": "2018-06-22T10:41:33.000+0000" }, { "id": "442754", "author": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "body": "*Closing ticket.* Verified fix in SDK Version {{7.5.0.v20181016071050}} using the examples from https://docs.appcelerator.com/platform/latest/#!/guide/iOS_Background_Services\r\n\r\n*Test environment*\r\n{code:java}\r\nAPPC Studio: 5.1.0.201808080937\r\niPhone 6 Sim (iOS 12)\r\nAPPC CLI: 7.0.6\r\nOperating System Name: Mac OS Mojave\r\nOperating System Version: 10.14\r\nNode.js Version: 8.9.1\r\nXcode 10.0\r\n{code}\r\n", "updateAuthor": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-18T10:51:30.000+0000", "updated": "2018-10-18T10:51:30.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }