IOS8 freezes in [GAIDataStore save]

I am tracking down a bug in my project that is causing the application to freeze, causing the user to reload.

This is only possible in a release build, so it was difficult to track. It is a social application where users upload photos to their profile. The problem only occurred on first launch after initial download or after reloading privacy settings and then across a stream to post a photo. During posting, the user is prompted to obtain permission to access the photos as well as access their location.

After selecting "Allow" in the search request, the application stopped responding.

So my initial research was on the use of the CLLocationManager, I suspected the issue was related to delegate callbacks.

I was unable to reproduce the debug config but was able to run the release config on the device and when the app stopped responding to the debugger pause the column points to the Google Analytics library.

0   0x37a9fb38 in __psynch_cvwait ()<br>
1   0x37b1c3f8 in _pthread_cond_wait ()<br>
2   0x37b1d2dc in pthread_cond_wait ()<br>
3   0x2aa3b482 in -[__NSOperationInternal _waitUntilFinished:] ()<br>
4   0x29c5799e in _CFXNotificationPost ()<br>
5   0x2a9879b8 in -NSNotificationCenter postNotificationName:object:userInfo: ()<br>
6   0x29a87b96 in -NSManagedObjectContext(_NSInternalAdditions) _didSaveChanges ()<br>
7   0x29a6e12e in -[NSManagedObjectContext save:] ()<br>
8   0x002d2e82 in __21-[GAIDataStore save:]_block_invoke ()<br>
9   0x002d16b8 in -GAIDataStore performBlockAndWait:withError: ()<br>
10  0x002d2dc2 in -[GAIDataStore save:] ()<br>
11  0x002db62a in -[GAIBatchingDispatcher persist:] ()<br>
12  0x002dc7aa in -[GAIBatchingDispatcher queueDispatch:] ()<br>
13  0x002dc5b0 in -[GAIBatchingDispatcher queueModel:] ()<br>
14  0x2aa5259e in __NSThreadPerformPerform ()<br>
15  0x29d0958e in _CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION_ ()<br>
16  0x29d0899e in __CFRunLoopDoSources0 ()<br>
17  0x29d07004 in __CFRunLoopRun ()<br>
18  0x29c55620 in CFRunLoopRunSpecific ()<br>
19  0x29c55432 in CFRunLoopRunInMode ()<br>
20  0x2a98d42c in -NSRunLoop(NSRunLoop) runMode:beforeDate: ()<br>
21  0x2a9db8ec in -NSRunLoop(NSRunLoop) run ()<br>
22  0x002cf270 in +[GAI threadMain:] ()<br>
23  0x2aa5238a in _NSThreadmain_ ()<br>
24  0x37b1ce92 in _pthread_body ()<br>
25  0x37b1ce06 in _pthread_start ()<br>

      

The problem only appears in iOS8 and I am running Google Analytics iOS SDK version 3.07.

The app is live and GAI was integrated for months before the bug hit when iOS8 was released. Several posts on issues with GAI integration report problems linking libraries, but I don't think this is the case because it works great in most cases.

If anyone has seen any problems with simmular or has any suggestions this would be helpful.

Thank,

+3


source to share


1 answer


You are listening NSManagedObjectContextDidSaveNotification

, the GAI SDK will post this notification, and the GAI SDK uses a different persistent store coordinator from yours, so if the GAI SDK publishes this notification and you try to merge the notification, you merge the changes of two different persistent stores, it might cause problems.

The solution is simple, when listening, NSManagedObjectContextDidSaveNotification

you only respond to the notification coming from the background context.
using a parameter object

in



[NSNotificationCenter -addObserver:selector:name:object:]

      

you can only listen to the background context, then the GAI context will not initiate a context merge.

+1


source







All Articles