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 2019/04/26 04:21:20 UTC

[GitHub] [cordova-plugin-media] HonchWong edited a comment on issue #174: iOS: Crash in [CDVSound startPlayingAudio:] with version 3.0.1 and 5.0.2

HonchWong edited a comment on issue #174: iOS: Crash in [CDVSound startPlayingAudio:] with version 3.0.1 and 5.0.2
URL: https://github.com/apache/cordova-plugin-media/issues/174#issuecomment-486919811
 
 
   If the whilt loop calls play 100 times, there is a big chance that it will crash. If you use serial queue, you can avoid crash.
   
   In my own project, I use serial queue call to play to avoid crashes,
   
   crash code:
   ```
   - (void)buttonAction {
       NSInteger testCount = 100;
       while (testCount) {
           testCount--;
           AVAudioPlayer *player = [self unusedPlayerWithPath:path];
           dispatch_async(dispatch_get_global_queue(0, 0), ^{
               if (player) {
                   [player play];
               }
           });
       }
   }
   ```
   
   safe code:
   ```
   - (void)buttonAction {
       NSInteger testCount = 100;
       while (testCount) {
           testCount--;
           AVAudioPlayer *player = [self unusedPlayerWithPath:path];
           dispatch_async(self.serialQueue,  ^{
               if (player) {
                   [player play];
               }
           });
       }
   }
   ```
   
   Cache all the files on the local file system, will it crash if you call the call 100 times in a loop?@sjkummer
   

----------------------------------------------------------------
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


With regards,
Apache Git Services

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