Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17826] iOS: Disabling analytics in tiapp.xml leads to iads crash on device

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-11-27T10:12:00.000+0000
Affected Version/sRelease 3.4.0
Fix Version/sRelease 3.4.2, Release 3.5.0, Release 4.0.0
ComponentsiOS
LabelsTCSupportTriage, analytics, device, iad, ios, module_analytics, qe-manualtest
ReporterDan Tamas
AssigneeChee Kiat Ng
Created2014-09-27T16:17:34.000+0000
Updated2014-11-27T10:12:00.000+0000

Description

If you disable the analytics in tiapp.xml and then try to use iAds it will crash with the following log:
[ERROR] The application has crashed with an uncaught exception 'NSInvalidArgumentException'.
[ERROR] Reason:
[ERROR] *** setObjectForKey: object cannot be nil (key: sid)
[ERROR] Stack trace:
[ERROR]   
[ERROR] 0   CoreFoundation                      0x240eae3f <redacted> + 126
[ERROR] 1   libobjc.A.dylib                     0x31798c8b objc_exception_throw + 38
[ERROR] 2   CoreFoundation                      0x24008ec3 <redacted> + 850
[ERROR] 3   Comnio                              0x0022de8f Comnio + 1871503
[ERROR] 4   Comnio                              0x0022febd Comnio + 1879741
[ERROR] 5   Foundation                          0x24de4ae1 <redacted> + 8
[ERROR] 6   Foundation                          0x24d4fb7d <redacted> + 148
[ERROR] 7   Foundation                          0x24d42337 <redacted> + 774
[ERROR] 8   Foundation                          0x24de744b <redacted> + 186
[ERROR] 9   libdispatch.dylib                   0x31d00651 <redacted> + 952
[ERROR] 10  libdispatch.dylib                   0x31cfb09d <redacted> + 84
[ERROR] 11  libdispatch.dylib                   0x31d01ba1 <redacted> + 320
[ERROR] 12  libdispatch.dylib                   0x31d02cd7 <redacted> + 94
[ERROR] 13  libsystem_pthread.dylib             0x31e59e31 _pthread_wqthread + 668
[ERROR] 14  libsystem_pthread.dylib             0x31e59b84 start_wqthread + 8
[ERROR] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: sid)'
[ERROR] *** First throw call stack:
[ERROR] (0x240eae3f 0x31798c8b 0x24008ec3 0x22de8f 0x22febd 0x24de4ae1 0x24d4fb7d 0x24d42337 0x24de744b 0x31d00651 0x31cfb09d 0x31d01ba1 0x31d02cd7 0x31e59e31 0x31e59b84)
^C 

The only place where I see an object with a key "sid" is the Geolocation module https://github.com/appcelerator/titanium_mobile/blob/ad9eea392dd7b0820c1b5f65c9147cf1ce4c8662/iphone/Classes/GeolocationModule.m#L525 that asks for a Ti.App.sessionId that seems to be set by the analytics. Putting back analytics to true in tiapp.xml fixes the issue, however it is not ok. How to reproduce: 1. Disable analytics in tiapp.xml
<analytics>false</analytics>
2. Add this is alloy.js (or anywhere)

iad = Titanium.UI.iOS.createAdView({
	adSize: Titanium.UI.iOS.AD_SIZE_PORTRAIT
});

Attachments

FileDateSize
monkey_console.txt2014-10-23T22:42:14.000+00001419
monkey_no_analytics.crash2014-10-23T22:42:14.000+000043942

Comments

  1. Fokke Zandbergen 2014-09-27

    That might even imply just geolocation module by itself only works with analyics enabled. Have you tested that? The Ti.App.sessionId is not set by analytics, but "just" an UUID set on boot: https://github.com/appcelerator/titanium_mobile/blob/ad9eea392dd7b0820c1b5f65c9147cf1ce4c8662/iphone/Classes/TiApp.m#L181
  2. Jon Alter 2014-09-29

    Hi [~rborn], We haven't been able to reproduce your issue using the instructions above. Below is a small sample that we have used to test for the crash when analytics is false on device. Please run it and let us know if reateAdView or forwardGeocoder cause the crash (If the issue was coming from geolocation then it should happen when calling forwardGeocoder). If this sample doesn't work, please include a sample that we can use to reproduce the issue. Also, what devices is this happening on?
       var win = Ti.UI.createWindow({
           backgroundColor: "#FFF"
       });
       win.open();
       
       win.addEventListener('click', function() {
           console.log('click');
           // Titanium.Geolocation.forwardGeocoder("440 N Bernardo Ave", function(evt) {
           //     console.log("callback");
           //     console.log(JSON.stringify(evt));
           // });
       
           var iad = Titanium.UI.iOS.createAdView({
               adSize: Titanium.UI.iOS.AD_SIZE_PORTRAIT
           });
           win.add(iad);
       });
       
  3. Dan Tamas 2014-09-30

    Sorry for the late reply I'm using few modules
       <modules>
               <module platform="iphone">com.widbook.blur</module>
               <module platform="iphone" version="1.7.4">dk.napp.social</module>
               <module platform="iphone" version="1.5.1">ti.admob</module>
               <module platform="iphone">facebook</module>
               <module platform="android" version="2.1.1">ti.admob</module>
               <module platform="android">facebook</module>
               <module platform="android">com.tripvi.drawerlayout</module>
               <module platform="iphone">bencoding.securely</module>
               <module platform="android">bencoding.securely</module>
               <module platform="android">de.marcelpociot.autofocus</module>
           </modules>
       
    I will try to run your test app with and without the modules, and mine as well to see if there is any of the modules that does this.
  4. Stephen Feather 2014-10-07

    Crittercism crash report (see symbolicated below)

       Name: NSInvalidArgumentException
       Reason: *** setObjectForKey: object cannot be nil (key: sid)
       App Version: 2.0.5
       Device: iPhone 6 (don't know if 6 or 6+)
       iOS Version: 8.0.2
       Reported: 2014-10-07 13:40:1412689212
       User: Anon.
       
       Stack Trace:
       
       0	CoreFoundation	0x2c078e3f __exceptionPreprocess + 127
       1	libobjc.A.dylib	0x39797c8b objc_exception_throw + 36
       2	CoreFoundation	0x2bf96ec3 -[__NSDictionaryM setObject:forKey:] + 848
       3	Uinterview	0x001c7627 0x000db000 + 968231
       4	Uinterview	0x001c9655 0x000db000 + 976469
       5	Foundation	0x2cd72ae1 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 6
       6	Foundation	0x2ccddb7d -[NSBlockOperation main] + 146
       7	Foundation	0x2ccd0337 -[__NSOperationInternal _start:] + 772
       8	Foundation	0x2cd7544b __NSOQSchedule_f + 184
       9	libdispatch.dylib	0x39cff651 _dispatch_queue_drain + 950
       10	libdispatch.dylib	0x39cfa09d _dispatch_queue_invoke + 82
       11	libdispatch.dylib	0x39d00ba1 _dispatch_root_queue_drain + 318
       12	libdispatch.dylib	0x39d01cd7 _dispatch_worker_thread3 + 92
       13	libsystem_pthread.dylib	0x39e58e31 _pthread_wqthread + 666
       14	libsystem_pthread.dylib	0x39e58b84 start_wqthread + 6
       

    Modules in use

       <module platform="commonjs">ti.cloud</module>    
           <module platform="iphone">dk.napp.drawer</module>
           <module platform="iphone">com.featherdirect.ticomscore</module>
           <module platform="iphone">facebook</module>
           <module platform="iphone">crittercism</module>
       

    Other

    iAds is used in the app. System Version: 8.0.2 iOS sdk target was 7.x
       <analytics>false</analytics>
       <sdk-version>3.4.0.v20140925164115</sdk-version>
       
    Had to use the patched libAPSAnalytics.a from TIMOB-17350 to get around the duplicate symbols error at the time.

    Symbolicated report

       Crashed Thread
       0	
       CoreFoundation 0x2c078e3f __exceptionPreprocess + 127
       1	
       libobjc.A.dylib 0x39797c8b objc_exception_throw + 36
       2	
       CoreFoundation 0x2bf96ec3 -[__NSDictionaryM setObject:forKey:] + 848
       3	
       Uinterview 0x001c7627 -[APSAnalytics queueEvent:type:data:immediate:] (APSAnalytics.m:449)
       4	
       Uinterview 0x001c9655 __54-[APSAnalytics sendCustomEvent:withEventType:payload:]_block_invoke_2 (APSAnalytics.m:855)
       5	
       Foundation 0x2cd72ae1 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 6
       6	
       Foundation 0x2ccddb7d -[NSBlockOperation main] + 146
       7	
       Foundation 0x2ccd0337 -[__NSOperationInternal _start:] + 772
       8	
       Foundation 0x2cd7544b __NSOQSchedule_f + 184
       9	
       libdispatch.dylib 0x39cff651 _dispatch_queue_drain + 950
       10	
       libdispatch.dylib 0x39cfa09d _dispatch_queue_invoke + 82
       11	
       libdispatch.dylib 0x39d00ba1 _dispatch_root_queue_drain + 318
       12	
       libdispatch.dylib 0x39d01cd7 _dispatch_worker_thread3 + 92
       13	
       libsystem_pthread.dylib 0x39e58e31 _pthread_wqthread + 666
       14	
       libsystem_pthread.dylib 0x39e58b84 start_wqthread + 6
       
  5. Jon Alter 2014-10-07

    Hey [~sfeather] - Any chance we could get some repro steps? Also, can you reproduce this issue without the other modules included in the project?
  6. Stephen Feather 2014-10-07

    This is an app in the wild. Simply confirming the bug by Dan. I do not know what steps took place to cause it. I changed the comment to add the symbolicated report which indicates its in the APSanalytics.m
  7. Muhammad Dadu 2014-10-07

  8. Dan Tamas 2014-10-08

    I tried to reproduce the bug in a new project, however I didn't manage to do it yet. I'll keep trying.
  9. Mario 2014-10-19

    I just ran into the same problem with an existing App and luckily found this ticket. Enabling Analytics in tiapp.xml fixed the iAd-Crash. Also using SDK 3.4.0GA (not tried the patch from TIMOB-17350 since I am OK with the analytics for now), iOS 8.0.2 on an iPhone 6. I'm using other modules then the ones mentioned in the other comments: {quote} ti.storekit ti.airprint com.0x82.dropbox com.0x82.key.chain ti.aws com.lightapps.icloudkeyvalue {quote} From what I see, it crashes in the analytics-conditional in bannerViewDidLoadAd in which it should not go because analytics is disabled. Looking at main.m I can see that TI_APPLICATION_ANALYTICS is correctly set to NO but for some reasons must evaluate differently in the iAd module.
  10. Jon Alter 2014-10-20

    Thanks for the info [~favo]. Agreed, it looks like the crash is here: https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/TiUIiOSAdView.m#L81 But we have still not been able to reproduce the issue on this end. Any info that will help us reproduce the issue will be greatly appreciated.
  11. Wilson Luu 2014-10-23

    I was able to reproduce this issue with SDK build 3.4.1.v20141022101712; looks like adView.show() is triggering the crash. *Steps to reproduce:* 1. Create a new Titanium classic app 2. In the tiapp.xml, look for *analytics* node and set to false 3. In the app.js, use the following code:
        var win = Ti.UI.createWindow({
            backgroundColor: 'white',
            layout: 'vertical' 
        });
        
        var adView = Ti.UI.iOS.createAdView({
            width : Ti.UI.FILL,
            height : Ti.UI.FILL,
            top : 10,
            backgroundColor: 'red'
        });
        
        win.add(adView);
        
        adView.show(); 
        win.open();
        
    4. Install app to device *Actual:* After the app launches and a couple of seconds, the app will crash; see monkey_console.txt and monkey_no_analytics.crash. *Tested on:* Appcelerator Studio, build: 3.4.1.201410191611 SDK build: 3.4.1.v20141022101712 CLI: 3.4.1-dev Alloy: 1.5.1 Xcode: 6.1 Devices: iphone 5 (8.1)
  12. Chee Kiat Ng 2014-10-24

    Thanks [~wluu]. Problem found and fixed. PR here: https://github.com/appcelerator/titanium_mobile/pull/6267 3_4_X PR: https://github.com/appcelerator/titanium_mobile/pull/6268
  13. Khushbu Agrawal 2014-11-26

    The Apple iAds view is showed without crash when the Analytics is turned off in tiApp.xml. Hence closing the ticket. Tested with below Environment: 1. Mac OSX Yosemite 10.10 2. Appcelerator Studio, build: 3.4.1.201410281743 3. Titanium SDK, build: 3.5.0.v20141125154115 4. Titanium CLI, build: 3.4.1 5. Alloy: 1.5.1 6. Xcode 6.1 7. iOS SDK 8.1 8. iPhone 5s with iOS 8.1

JSON Source