2

Using the Google Analytics library for iOS version 3.0.9, (and 3.0.x in general), we see a lot of crashes like the one below.

They appeared to occur randomly.

Exception Type:  SIGBUS
Exception Codes: BUS_ADRALN at 0xe756c0
Crashed Thread:  19

Thread 19 Crashed:
0   libsystem_platform.dylib            0x39e02e18 0x39e01000 + 7704
1   CoreFoundation                      0x2bfd0d6f 0x2bf92000 + 257391
2   CoreFoundation                      0x2c0716a3 0x2bf92000 + 915107
3   CoreFoundation                      0x2c070417 0x2bf92000 + 910359
4   CoreFoundation                      0x2bfd4a0b 0x2bf92000 + 272907
5   Communicator                        0x00714541 +[GAIUsageTracker trackTarget:action:] + 193
6   Communicator                        0x007049b3 -[GAITrackerImpl send:] + 47
7   Communicator                        0x00157b8d __66+[xxx]_block_invoke (xxx.m:305)
8   libdispatch.dylib                   0x39ca58cb 0x39ca4000 + 6347
9   libdispatch.dylib                   0x39caeda3 0x39ca4000 + 44451
10  libdispatch.dylib                   0x39cafcd7 0x39ca4000 + 48343
11  libsystem_pthread.dylib             0x39e06e31 0x39e06000 + 3633

1 Answer 1

1

It turns out that the GAI library is not as thread-safe as it claims. We were able to fix our Google Analytics crashes by serializing the calls.

      (void (^)(void))block = {
       // your analytics call, eg
       [[[GAI sharedInstance] defaultTracker] send:....];
      };
      static dispatch_queue_t theQueue;
      static dispatch_once_t onceToken;
      dispatch_once(&onceToken, ^{
        theQueue = dispatch_queue_create("Analytics Queue", DISPATCH_QUEUE_SERIAL);
      });

      dispatch_async(theQueue, block);

So all calls to the tracker are executed in code blocks serialized on the same queue ("theQueue" above), which forces only one code block to execute at a time.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.