AbdFatah / analytics-issues

Automatically exported from code.google.com/p/analytics-issues
0 stars 0 forks source link

CRASH: GANTracker IOS startTrackerWithAccountID needs sqlite3 error checking #162

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Name of affected component: Mobile Tracking

Name of related library and version, if applicable (e.g. Android, iOS,
Snippets, etc.): iOS, all versions

Issue summary:
Random Crash happens on GANTracker startup on IOS, possibly due to lack of 
sqlite3 errorchecking when IOS app suspend corrupts sqlite3 database

Steps to reproduce issue:
1. Create app, install vanilla version of GANTracker
2. Cause GANTracker's sqlite3 database to corrupt while app is suspending
3. On future app startups -> CRASH!

Expected output:
I expect the GANTracker sqlite3 code to fail gracefully, or at least allow a 
try/catch for the exception- please add error-checking for sqlite3 cmds!

Actual results:
Crash for MANY users, especially with IOS5 upgrade, with varying Exceptions::
NSInternalInconsistencyException: Error: Failed to prepare select session 
statement 
NSInternalInconsistencyException: Error: Failed to prepare update timestamp 
statement
NSInternalInconsistencyException: Error: Failed to prepare select 
custom_var_cache statement: 1

Notes:
Many developers have encountered this, with no response from Google::
http://stackoverflow.com/questions/7054508/ios-google-analytics-crash-at-start-u
p-randomly/7071912#7071912
http://www.google.com/support/forum/p/Google+Analytics/thread?tid=61ef8c78a773c0
4d&hl=en
http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=20107fa00aae
4f08&hl=en

STACK TRACE:::::::::::::::::::::::::::::::
Exception: NSInternalInconsistencyException: Error: Failed to prepare select 
session statement

0   CoreFoundation                      0x3759dc7b __exceptionPreprocess + 114
1   libobjc.A.dylib                     0x32d9bee8 objc_exception_throw + 40
2   CoreFoundation                      0x3759dac3 +[NSException 
raise:format:arguments:] + 70
3   Foundation                          0x351a3e73 -[NSAssertionHandler 
handleFailureInMethod:object:file:lineNumber:description:] + 62
4   mySampleApp2                        0x000edd25 -[GANPersistentEventStore 
initializeSession] + 124
5   mySampleApp2                        0x000ed8c5 -[GANPersistentEventStore 
initWithPath:] + 60
6   mySampleApp2                        0x000ed881 -[GANPersistentEventStore 
init] + 16
7   mySampleApp2                        0x000ed4a3 -[GANTracker 
startTrackerWithAccountID:dispatchPeriod:delegate:] + 198
8   mySampleApp2                        0x00006ce9 -[myAppDelegate 
application:didFinishLaunchingWithOptions:] + 48

SAMPLE CODE::::::::::::::::::::::::
#define GAKey @“UA-xxxxxx-x"

static const NSInteger kGANDispatchPeriodSec = 10;
[[GANTracker sharedTracker] startTrackerWithAccountID:GAKey
                                       dispatchPeriod:kGANDispatchPeriodSec
                                             delegate:nil];

MORE INFO ON REPLICATING SQLITE CORRUPTION DURING APP SUSPEND:::::::::
https://devforums.apple.com/message/566950

"... this happens when application goes background (pressed home button) and it 
only happens when I wipe out underlying persistent store coordinate with sqlite 
file too. I want to remove database file and reinitialize CoreData stack."

ALTERNATE STACK TRACE FROM SOMEONE ELSE'S CRASH:::::::::::::::::::::::::::::
from 
https://www.google.com/support/forum/p/Google+Analytics/thread?tid=61ef8c78a773c
04d&hl=en

Application Specific Information:
*** Terminating app due to uncaught exception 
'NSInternalInconsistencyException', reason: 'Error: Failed to prepare select 
custom_var_cache statement: 1'

Thread 0 Crashed:
0   libSystem.B.dylib                   0x00090b2c __kill + 8
1   libSystem.B.dylib                   0x00090b15 raise + 17
2   xxxx                             0x0010ec3d uncaught_exception_handler 
(PLCrashReporter.m:137)
3   CoreFoundation                      0x00094e23 __handleUncaughtException + 
231
4   libobjc.A.dylib                     0x00008894 _objc_terminate + 156
5   libstdc++.6.dylib                   0x00063a8c __cxxabiv1::__terminate(void 
(*)()) + 84
6   libstdc++.6.dylib                   0x00063b04 std::terminate() + 24
7   libstdc++.6.dylib                   0x00063c2c __cxa_throw + 108
8   libobjc.A.dylib                     0x00006e5c objc_exception_throw + 112
9   CoreFoundation                      0x00026b33 +[NSException 
raise:format:arguments:] + 83
10  Foundation                          0x0007b2bb -[NSAssertionHandler 
handleFailureInMethod:object:file:lineNumber:description:] + 63
11  xxxx                           0x00103559 -[GANPersistentHitStore 
getVisitorVarBuffer] (GANPersistentHitStore.m:980)
12  xxxx                             0x00101759 -[GANPersistentHitStore 
putCustomVariables:] (GANPersistentHitStore.m:912)
13  xxxx                             0x001029dd -[GANPersistentHitStore 
putEvent:allowSessionUpdate:withError:] (GANPersistentHitStore.m:841)
14  xxxx                            0x00102e89 -[GANPersistentHitStore 
migrateEventsToHits] (GANPersistentHitStore.m:1115)
15  xxxx                             0x0010270d -[GANPersistentHitStore 
openDataBase:] (GANPersistentHitStore.m:333)
16  xxxx                             0x00100f21 -[GANPersistentHitStore 
initWithHitBuilder:path:] (GANPersistentHitStore.m:136)
17  xxxx                             0x00100eb9 -[GANPersistentHitStore 
initWithHitBuilder:] (GANPersistentHitStore.m:127)
18  xxxx                             0x001060c5 -[GANTracker 
startTrackerWithAccountID:dispatchPeriod:delegate:] (GANTracker.m:129)
19  xxxx                             0x0002590f -[AnalyticsManager 
startTracking] (AnalyticsManager.m:408)
20  xxxx                             0x000385e9 -[AppDelegate 
application:didFinishLaunchingWithOptions:] (DaftAppDelegate.m:119)
21  UIKit                               0x00004e48 -[UIApplication 
_performInitializationWithURL:sourceBundleID:] + 476
22  UIKit                               0x00004a68 -[UIApplication 
_runWithURL:sourceBundleID:] + 584
23  UIKit                               0x00055e00 -[UIApplication 
handleEvent:withNewEvent:] + 1524
24  UIKit                               0x0005563c -[UIApplication sendEvent:] 
+ 68
25  UIKit                               0x00055094 _UIApplicationHandleEvent + 
4536
26  GraphicsServices                    0x000057e4 PurpleEventCallback + 1052
27  CoreFoundation                      0x0005752b CFRunLoopRunSpecific + 2303
28  CoreFoundation                      0x00056c1f CFRunLoopRunInMode + 51
29  UIKit                               0x00003c08 -[UIApplication _run] + 520
30  UIKit                               0x00002230 UIApplicationMain + 968
31  xxxx                             0x00002337 main (main.m:14)

Original issue reported on code.google.com by m...@foodspotting.net on 27 Oct 2011 at 10:28

GoogleCodeExporter commented 9 years ago
Thanks for reporting this. What version of the SDK are you using?

Original comment by fm...@google.com on 31 Oct 2011 at 8:07

GoogleCodeExporter commented 9 years ago
currently 1.3, but this happened in 1.2 as well.

Original comment by m...@foodspotting.net on 31 Oct 2011 at 8:24

GoogleCodeExporter commented 9 years ago
I believe this to be fixed in the next version of the SDK, which is set to be 
released within the next 1-2 weeks. Thanks for your patience and for filing 
this report.

Original comment by fm...@google.com on 7 Nov 2011 at 10:23

GoogleCodeExporter commented 9 years ago
i certainly hope so...please rush the release

Original comment by cesar...@gmail.com on 16 Nov 2011 at 8:41

GoogleCodeExporter commented 9 years ago
Fixed in 1.4 SDK

Original comment by nrho...@google.com on 18 Nov 2011 at 10:56