{"action":"created","issue":{"url":"https://api.github.com/repos/Adobe-Marketing-Cloud/mobile-services/issues/284","repository_url":"https://api.github.com/repos/Adobe-Marketing-Cloud/mobile-services","labels_url":"https://api.github.com/repos/Adobe-Marketing-Cloud/mobile-services/issues/284/labels{/name}","comments_url":"https://api.github.com/repos/Adobe-Marketing-Cloud/mobile-services/issues/284/comments","events_url":"https://api.github.com/repos/Adobe-Marketing-Cloud/mobile-services/issues/284/events","html_url":"https://github.com/Adobe-Marketing-Cloud/mobile-services/issues/284","id":333827420,"node_id":"MDU6SXNzdWUzMzM4Mjc0MjA=","number":284,"title":"NSUserDefaults KVO conflict with Adobe DMP (revisited)","user":{"login":"khopwood","id":847420,"node_id":"MDQ6VXNlcjg0NzQyMA==","avatar_url":"https://avatars2.githubusercontent.com/u/847420?v=4","gravatar_id":"","url":"https://api.github.com/users/khopwood","html_url":"https://github.com/khopwood","followers_url":"https://api.github.com/users/khopwood/followers","following_url":"https://api.github.com/users/khopwood/following{/other_user}","gists_url":"https://api.github.com/users/khopwood/gists{/gist_id}","starred_url":"https://api.github.com/users/khopwood/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khopwood/subscriptions","organizations_url":"https://api.github.com/users/khopwood/orgs","repos_url":"https://api.github.com/users/khopwood/repos","events_url":"https://api.github.com/users/khopwood/events{/privacy}","received_events_url":"https://api.github.com/users/khopwood/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-06-19T20:31:04Z","updated_at":"2018-07-16T18:49:42Z","closed_at":null,"author_association":"NONE","body":"Our top crash for 2 of our applications started happening as soon as we integrated Adobe DMP and is in a thread where adobe is setting a value in NSUserDefaults, and is crashing during the KVO. \r\n\r\nYou have a very similar crash report here: \r\nhttps://github.com/Adobe-Marketing-Cloud/mobile-services/issues/264\r\n that you stated that this was not Adobe’s fault, and you should look at who is observing the user defaults. \r\n\r\nThis is reasonable to some extent, but I think there are reasons to consider that adobe’s code may not be idea. \r\n\r\nSome points\r\n* The adobe code happens very early in our launch, far earlier than we initialize DMP\r\n* It is setting a value on a background thread which should be safe, but I wonder if it may conflict if someone is unregistering on a different thread. \r\n* This crash started when we integrated DMP\r\n* Happens only on the targets that link the library\r\n* Is always due to Adobe setting a preference\r\n* iOS 11 only\r\n* The only client adding an observer on NSUserDefaults is [GTMLogLevelFilter.](https://github.com/google/google-toolbox-for-mac/blob/master/Foundation/GTMLogger.m) It removes the observer when dealloc. It is allocated twice on launch, and deallocated once, so there is an unregister happening during this time. \r\n\r\nMy guess is  it is a thread conflict is when GTMLogLevelFilter is removing observation, and Adobe is setup a value on a different thread. \r\n\r\n**My question** is why is Adobe running before we are invoking it. If we could control when Adobe is running we could avoid this conflict. \r\n\r\n```\r\nCrashed: com.adobe.analytics.processing\r\n0  libobjc.A.dylib                0x1824d0430 objc_msgSend + 16\r\n1  Foundation                     0x183c33f40 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:usingBlock:] + 704\r\n2  Foundation                     0x183c3394c -[NSObject(NSKeyValueObservingPrivate) _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:] + 612\r\n3  CoreFoundation                 0x1832ab36c -[CFPrefsSource forEachObserver:] + 288\r\n4  CoreFoundation                 0x1832abcfc -[CFPrefsSource _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:] + 76\r\n5  CoreFoundation                 0x18320fb2c __93-[CFPrefsSearchListSource deferredNotifyCausedByLoadingOfChangesFromDictionary:toDictionary:]_block_invoke + 36\r\n6  CoreFoundation                 0x1832b2cd8 _CFPrefsDeliverPendingKVONotifications + 112\r\n7  CoreFoundation                 0x183211310 __108-[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke + 300\r\n8  CoreFoundation                 0x183210b0c normalizeQuintuplet + 356\r\n9  CoreFoundation                 0x1832111d8 -[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:] + 108\r\n10 CoreFoundation                 0x1832b5a4c -[_CFXPreferences setValue:forKey:appIdentifier:container:configurationURL:] + 92\r\n11 CoreFoundation                 0x1832b90cc _CFPreferencesSetAppValueWithContainer + 128\r\n12 Foundation                     0x183b7be30 -[NSUserDefaults(NSUserDefaults) setObject:forKey:] + 68\r\n```"},"comment":{"url":"https://api.github.com/repos/Adobe-Marketing-Cloud/mobile-services/issues/comments/405343278","html_url":"https://github.com/Adobe-Marketing-Cloud/mobile-services/issues/284#issuecomment-405343278","issue_url":"https://api.github.com/repos/Adobe-Marketing-Cloud/mobile-services/issues/284","id":405343278,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNTM0MzI3OA==","user":{"login":"khopwood","id":847420,"node_id":"MDQ6VXNlcjg0NzQyMA==","avatar_url":"https://avatars2.githubusercontent.com/u/847420?v=4","gravatar_id":"","url":"https://api.github.com/users/khopwood","html_url":"https://github.com/khopwood","followers_url":"https://api.github.com/users/khopwood/followers","following_url":"https://api.github.com/users/khopwood/following{/other_user}","gists_url":"https://api.github.com/users/khopwood/gists{/gist_id}","starred_url":"https://api.github.com/users/khopwood/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khopwood/subscriptions","organizations_url":"https://api.github.com/users/khopwood/orgs","repos_url":"https://api.github.com/users/khopwood/repos","events_url":"https://api.github.com/users/khopwood/events{/privacy}","received_events_url":"https://api.github.com/users/khopwood/received_events","type":"User","site_admin":false},"created_at":"2018-07-16T18:49:42Z","updated_at":"2018-07-16T18:49:42Z","author_association":"NONE","body":"thanks Steve ( sorry I was on vacation for a few days ). \r\nI will open an issue with client care as well. "}}
{"actor":{"display_login":"khopwood"}}