Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27278] iOS: App crashes upon giving permission to Calendar

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2019-07-26T18:11:34.000+0000
Affected Version/sRelease 8.1.0
Fix Version/sRelease 8.1.0
ComponentsiOS
LabelsengSchedule, regression
ReporterSatyam Sekhri
AssigneeVijay Singh
Created2019-07-24T23:22:45.000+0000
Updated2019-07-26T18:11:34.000+0000

Description

One of the test apps crashes as soon as permission to Calendar is provided upon app launch. This is a regression as the app works fine in 8.0.2.GA Steps To Reproduce: 1. Get the test app from https://github.com/appcelerator/qe-FeatureTest/tree/master/Media/MediaModule 2. Run it on iOS simulator 3. Upon app launch there is a prompt for permission to Calendar. Allow permission. 4. Relaunch the app. Now it requests permission to contacts and camera. Grant permissions Actual Result: After Step 3: The app crashes. Below are the logs. However the permission to Calendar are granted. After Step 4: Permission granted successfully and no crash happens this time.
[INFO]  MediaModule 1.0 (Powered by Titanium 8.1.0.3dab0b3)
[INFO]  Calendar Permissions Granted
[ERROR] The application has crashed with an uncaught exception 'NSInvalidArgumentException'.
[ERROR] Reason:
[ERROR] *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]
[ERROR] Stack trace:
[ERROR] 0   CoreFoundation                      0x000000010a9d18db __exceptionPreprocess + 331
[ERROR] 1   libobjc.A.dylib                     0x00000001097deac5 objc_exception_throw + 48
[ERROR] 2   CoreFoundation                      0x000000010a91ffac _CFThrowFormattedException + 194
[ERROR] 3   CoreFoundation                      0x000000010aa3de11 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 321
[ERROR] 4   CoreFoundation                      0x000000010a9cd5bb +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
[ERROR] 5   TitaniumKit                         0x00000001096ba4f2 __34-[KrollBridge didStartNewContext:]_block_invoke + 405
[ERROR] 6   CoreFoundation                      0x000000010a9d86ac __invoking___ + 140
[ERROR] 7   CoreFoundation                      0x000000010a9d5c25 -[NSInvocation invoke] + 325
[ERROR] 8   JavaScriptCore                      0x00000001049a00f8 _ZN3JSC24ObjCCallbackFunctionImpl4callEP9JSContextP13OpaqueJSValuemPKPKS3_PS6_ + 440
[ERROR] 9   JavaScriptCore                      0x000000010499fb17 _ZN3JSCL34objCCallbackFunctionCallAsFunctionEPK15OpaqueJSContextP13OpaqueJSValueS4_mPKPKS3_PS6_ + 247
[ERROR] 10  JavaScriptCore                      0x000000010499f3bc _ZN3JSC19APICallbackFunction4callINS_20ObjCCallbackFunctionEEExPNS_9ExecStateE + 492
[ERROR] 11  JavaScriptCore                      0x000000010497ad88 vmEntryToNative + 206
[ERROR] 12  JavaScriptCore                      0x0000000104d60f4a _ZN3JSC11Interpreter11executeCallEPNS_9ExecStateEPNS_8JSObjectENS_8CallTypeERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 538
[ERROR] 13  JavaScriptCore                      0x0000000104fa6d6e _ZN3JSC4callEPNS_9ExecStateENS_7JSValueENS_8CallTypeERKNS_8CallDataES2_RKNS_7ArgListE + 62
[ERROR] 14  JavaScriptCore                      0x0000000104ff98ac _ZN3JSC10callGetterEPNS_9ExecStateENS_7JSValueES2_ + 140
[ERROR] 15  JavaScriptCore                      0x0000000104e5592f llint_slow_path_get_by_id + 6047
[ERROR] 16  JavaScriptCore                      0x00000001049810a5 llint_entry + 25234
[ERROR] 17  JavaScriptCore                      0x000000010498a01f llint_entry + 61964
[ERROR] 18  JavaScriptCore                      0x000000010497ac59 vmEntryToJavaScript + 200
[ERROR] 19  JavaScriptCore                      0x0000000104d60f03 _ZN3JSC11Interpreter11executeCallEPNS_9ExecStateEPNS_8JSObjectENS_8CallTypeERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 467
[ERROR] 20  JavaScriptCore                      0x0000000104fa6ed4 _ZN3JSC12profiledCallEPNS_9ExecStateENS_15ProfilingReasonENS_7JSValueENS_8CallTypeERKNS_8CallDataES3_RKNS_7ArgListE + 196
[ERROR] 21  JavaScriptCore                      0x00000001049c6018 JSObjectCallAsFunction + 488
[ERROR] 22  JavaScriptCore                      0x0000000104998436 -[JSValue callWithArguments:] + 278
[ERROR] 23  MediaModule                         0x00000001044cd2e5 __53-[CalendarModule requestAuthorization:forEntityType:]_block_invoke_2 + 325
[ERROR] 24  TCC                                 0x0000000112849e1a __TCCAccessRequest_block_invoke.71 + 438
[ERROR] 25  TCC                                 0x000000011284dbdb __tccd_send_message_block_invoke + 231
[ERROR] 26  libxpc.dylib                        0x000000010d1407dd _xpc_connection_reply_callout + 36
[ERROR] 27  libxpc.dylib                        0x000000010d1354dc _xpc_connection_call_reply_async + 86
[ERROR] 28  libdispatch.dylib                   0x000000010ce07d6c _dispatch_client_callout3 + 8
[ERROR] 29  libdispatch.dylib                   0x000000010ce1f468 _dispatch_mach_msg_async_reply_invoke + 332
[ERROR] 30  libdispatch.dylib                   0x000000010ce17923 _dispatch_kevent_worker_thread + 1427
[ERROR] 31  libsystem_pthread.dylib             0x000000010d1e9615 _pthread_wqthread + 419
[ERROR] 32  libsystem_pthread.dylib             0x000000010d1e9405 start_wqthread + 13

Comments

  1. Vijay Singh 2019-07-25

    This issue is due to [this PR](https://github.com/appcelerator/titanium_mobile/pull/10381). Specially due to [this commit](https://github.com/appcelerator/titanium_mobile/pull/10381/commits/d1854f785f782e4a5d2967ea86d4fccf65aab1c3#diff-9c72c1d05854e98bac7ba54095bb7bfbR192). As reverting this works fine. cc [~cwilliams] Test Case -
       function askCalendarPermission(){
           if (Ti.Calendar.hasCalendarPermissions()) {
               Ti.Calendar.getAllCalendars();
               askContactPermission();         
               } else {
                  Ti.Calendar.requestCalendarPermissions(function(e) {
                      if (e.success === true) {
                         Ti.API.info("Calendar Permissions Granted");
                         Ti.Calendar.getAllCalendars();
                         askContactPermission();
                      } else {
                         alert("Access denied, error: " + e.error);
                      }
                  });
               }
       }
       
       function askContactPermission(){
           if (Ti.Contacts.hasContactsPermissions()) {
                   Ti.Contacts.getAllPeople();
                  askCameraPermissions(); 
               } else {
                  Ti.Contacts.requestContactsPermissions(function(e) {
                      if (e.success === true) { 
                         Ti.API.info("Contacts Permissions Granted");
                         Ti.Contacts.getAllPeople();
                         askCameraPermissions(); 
                      } else {
                         alert("Access denied, error: " + e.error);
                      }
                  });
               }
       }
       
       //Added camera permissions in the tiapp.xml for camera because permissions get added to the android manifest only if showCamera() is called below. But its not fesible here as opening a camera before app launches just to add camera permissions looks stupid.
       function askCameraPermissions(){
       if (Ti.Media.hasCameraPermissions()) {
             // require('ui').createApplicationTabGroup().open();    
          } else { 
              Ti.Media.requestCameraPermissions(function(e) {
                       if (e.success === true) {
                           Ti.API.info("Camera Permissions Granted");
                           //require('ui').createApplicationTabGroup().open();
                       } else {
                           alert("Access denied, error: " + e.error);
                       }
              });
          }
       }
       
       askCalendarPermission();
       
  2. Vijay Singh 2019-07-25

    PR(8_1_X) - https://github.com/appcelerator/titanium_mobile/pull/11078 PR(master) - https://github.com/appcelerator/titanium_mobile/pull/11079
  3. Keerthi Mahalingam 2019-07-25

    FR passed. danger failed. so not able to merge
  4. Lokesh Choudhary 2019-07-26

    Backport Merged.
  5. Lokesh Choudhary 2019-07-26

    Master merged.
  6. Keerthi Mahalingam 2019-07-26

    Verified the fix on sdk 8.2.0.v20190726102118 and 8.1.0.v20190726095146 .NO crashing on calendar permission.works as expected. Test Environment:
         Name                        = Mac OS X
         Version                     = 10.14.5
         Architecture                = 64bit
       Node.js
         Node.js Version             = 10.16.0
         npm Version                 = 6.9.0
       Titanium CLI
         CLI Version                 = 5.1.1
       Titanium SDK
         SDK Version                 = 8.2.0.v20190726102118 and 8.1.0.v20190726095146
       Device =iPhone X iOS 11
       Simulator =iPhone 6 iOS 11,iphone xs iOS 12.4
       

JSON Source