You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2020/07/21 21:03:59 UTC

[GitHub] [cordova-plugin-contacts] vmdominguez-usaa opened a new issue #225: Possible deadlock in iOS queue management code

vmdominguez-usaa opened a new issue #225:
URL: https://github.com/apache/cordova-plugin-contacts/issues/225


   <!--
   Please have a look at the issue templates you get when you click "New issue" in the GitHub UI.
   We very much prefer issues created by using one of these templates.
   -->
   
   ### Issue Type
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x] Bug Report
   - [ ] Feature Request
   - [ ] Support Question
   
   ## Description
   While performing regression testing with the iOS 14 beta, I discovered that my app would crash when attempting to remove a contact. After doing some digging, it appears to be caused by potentially unnecessary calls `dispatch_sync`.
   
   ## Information
   <!-- Include all relevant information that might help understand and reproduce the problem -->
   While troubleshooting, I came upon [this StackOverflow answer](https://stackoverflow.com/a/10998307), which indicates that calling `dispatch_sync` targeting the current queue is a no-no. Through debugging my app, I discovered that this is indeed the scenario under which my app was crashing. It does not appear to crash on devices with iOS 13.
   
   I believe I confirmed the source of the problem by changing the code in `CDVContacts.m` (`createAddressBook`) from
   ```objc
               dispatch_sync(dispatch_get_main_queue(), ^{
                   if (error) {
                       workerBlock(NULL, [[CDVAddressBookAccessError alloc] initWithCode:UNKNOWN_ERROR]);
                   } else if (!granted) {
                       workerBlock(NULL, [[CDVAddressBookAccessError alloc] initWithCode:PERMISSION_DENIED_ERROR]);
                   } else {
                       // access granted
                       workerBlock(addressBook, [[CDVAddressBookAccessError alloc] initWithCode:UNKNOWN_ERROR]);
                   }
               });
   ```
   to
   ```objc
           dispatch_block_t onMain = ^{
               if (error) {
                   workerBlock(NULL, [[CDVAddressBookAccessError alloc] initWithCode:UNKNOWN_ERROR]);
               } else if (!granted) {
                   workerBlock(NULL, [[CDVAddressBookAccessError alloc] initWithCode:PERMISSION_DENIED_ERROR]);
               } else {
                   // access granted
                   workerBlock(addressBook, [[CDVAddressBookAccessError alloc] initWithCode:UNKNOWN_ERROR]);
               }
           };
           
           if ([NSThread isMainThread]) {
               onMain();
           } else {
               // callback can occur in background, address book must be accessed on thread it was created on
               dispatch_sync(dispatch_get_main_queue(), onMain);
           }
   ```
   After I made this change locally and re-ran the app, the contact was successfully removed.
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   `Contact.remove` from @ionic-native/contacts
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you experiencing the issue? -->
   crashed on iPad Pro: iPadOS 14 beta 2
   did not crash on iPhoone XS iOS 13.6
   
   
   ### Version information
   <!-- 
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins 
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   Cordova: 9
   cordova-ios: 5.1.1
   cordova-plugin-contacts: 3.0.1
   Ionic: 3
   @ionic-native/contacts: 4.1.0
   
   
   ## Checklist
   <!-- Please check the boxes by putting an `x` in the `[ ]` like so: `[x]` -->
   
   - [x] I searched for already existing GitHub issues about this
   - [ ] I updated all Cordova tooling to their most recent version (this is an enterprise app for my employer -- our app stack is outdated)
   - [x] I included all the necessary information above
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-plugin-contacts] Anuj-Raghuvanshi commented on issue #225: Possible deadlock in iOS queue management code

Posted by GitBox <gi...@apache.org>.
Anuj-Raghuvanshi commented on issue #225:
URL: https://github.com/apache/cordova-plugin-contacts/issues/225#issuecomment-699638316


   Even I am getting crash when it asks for initial permissions.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org