1

I'm trying to use Google Analytics SDK v3.10 for iOS.

I added all dependencies and headers, then in my app delegate, method :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

, I added those lines :

[[GAI sharedInstance] setDispatchInterval:20.0];
[[GAI sharedInstance] trackerWithTrackingId:@"UA-XXXXXXXX-X"];
[[GAI sharedInstance].logger setLogLevel:kGAILogLevelVerbose];

with the proper tracking id.

In my landing view, method viewDidAppear, I added the lines

id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:kGAIScreenName value:@"MyLandingView"];
[tracker send:[[GAIDictionaryBuilder createAppView] build]];

It leads to an horrible memory leak (about +1mb/s) and a freeze with those logs :

Apr 20 08:07:47 iPad-of-Pitt MyAppName[920] <Warning>: void SendDelegateMessage(NSInvocation *): delegate (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode

Is this a known bug ? Any clue on how to avoid that ?

Thanks in advance !

EDIT : duplicated this question in google groups https://groups.google.com/forum/?fromgroups#!topic/ga-mobile-app-analytics/0goRZOc3vk0

EDIT 2 : also posted the issue here https://code.google.com/p/analytics-issues/issues/detail?id=617&thanks=617&ts=1429543879

Pierre Mardon
  • 727
  • 8
  • 25
  • Is this a known bug ? Any clue on how to avoid that ? (no idea but I can ping the Dev team and find out) – Linda Lawton - DaImTo Apr 20 '15 at 11:25
  • FYI @DaImTo , the first suggestion of the "Getting help" page of GA is : _The best place to ask questions about using and developing with Google Analytics APIs, libraries, and SDKs is on Stack Overflow or in one of the offical Analytics developer forums._ – Pierre Mardon Apr 20 '15 at 15:49
  • Yup and the reason for that is that they monitor this forum. I just heard back an issue was opened and Someone is looking into it. – Linda Lawton - DaImTo Apr 20 '15 at 15:51
  • Do you have a link to the issue you mention or is it mine ? You say "Someone is looking into it " ? Who and where do you see that ? Also I may have misunderstood your first comment that sounds like "You didn't do your homework" to me, and it's why I posted my two previous comments. – Pierre Mardon Apr 20 '15 at 16:18
  • The bug is logged internally with the Google Analytics developers team it's not something you can see. I emailed them your problem directly. They email me back that they have logged it as an issue – Linda Lawton - DaImTo Apr 20 '15 at 16:39
  • I don't think Analytics is making any use of webView. Do you use webView in your app? From your description this seem related the use of webView and not to Analytics. – djabi Apr 22 '15 at 00:19
  • Yes but I don't deal with it for my GA tests. – Pierre Mardon Apr 22 '15 at 08:12

2 Answers2

3

I had the same issue.

In my case that was because I use Core Data and NSManagedObjectContextDidSaveNotification to merge updates from a background process, resulting in a exception as described in this post :

The solution I used was to add the managedObjectContext itself as object of the NSNotificaition declaration :

ObjC

[[NSNotificationCenter defaultCenter] addObserver:self 
                                  selector:@selector(managedObjectContextDidSave:) 
                                  name:NSManagedObjectContextDidSaveNotification 
                                  object:self.managedObjectContext];

Swift

NSNotificationCenter.defaultCenter().addObserverForName(NSManagedObjectContextDidSaveNotification,
            object: self.managedObjectContext,
            queue: nil)

Did the trick for me, no more memory leak.

Hope it could help.

Mory
  • 198
  • 9
-1

Once the events are fired, it will take a couple of minutes to get reflected in dashboard. IT is expected that the user should have little patience. This is one way of looking at it.

With respect to code, It is better to dispatch the events manually. IT will certainly get reflected in dashboard.

id newTracker = [[GAI sharedInstance]trackerWithTrackingId:googlePropertyId];
[GAI sharedInstance].defaultTracker = newTracker; // Set newTracker as the default tracker globally.
[GAI sharedInstance].debug = YES;
DebugLog(@"Events log : %@",objAnalytics.event_description);
[newTracker trackEventWithCategory:objAnalytics.event_name
                            withAction:objAnalytics.event_description
                             withLabel:objAnalytics.event_name
                             withValue:[NSNumber numberWithInt:100]];

Please try dispatching the events manually. This will work for sure (at least it worked for me this way).

[[GAI sharedInstance]dispatch];
  • Your code is not compliant with 3.10 SDK (there is no debug property on GAI). Setting the only instanciated tracker as the default one makes no sense. You don't address my main concern : the memory leak. So I downvoted your answer. Thanks anyway ! – Pierre Mardon Apr 20 '15 at 15:10