You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2021/08/01 04:43:12 UTC

[GitHub] [cordova-plugin-media] pslyman opened a new issue #309: [iOS] Stalled Playback

pslyman opened a new issue #309:
URL: https://github.com/apache/cordova-plugin-media/issues/309


   # Bug Report
   On iOS, when seeking with `media.seekTo()` or playing audio (streaming from link) for an arbitrary amount of time, playback will stop unexpectedly. 
   
   ## Problem
   
   ### What is expected to happen?
   Audio should play uninterrupted. 
   
   
   ### What does actually happen?
   Audio stops unexpectedly. 
   
   
   ## Information
   <!-- Include all relevant information that might help understand and reproduce the problem -->
   Xcode outputs the following message. 
   ```
   [Symptoms] {
     "transportType" : "HTTP Progressive Download",
     "mediaType" : "HTTP Progressive Download",
     "BundleID" : "myBundleID",
     "name" : "MEDIA_PLAYBACK_STALL",
     "interfaceType" : "Wifi"
   }
   ```
   as well as 
   ```
   Stalled playback
   ```
   
   After trying to pause and replay 
   ```
   Playing audio sample 'https://remotelocation/audio.mp3'
   
   Playing stream with AVPlayer & default rate
   ```
   And then returning the `MEDIA_PLAYBACK_STALL` issue from early almost immediately.  
   
   Upon investigating the issue, I discovered that this can happen when the audio buffer is not filled, and at least not filled in time for the audio playback. I cannot reproduce this on web, or on Android. Only on iOS do I have this problem. This happens on an emulator and a physical device (iPhone SE, iOS 14.7.1).
   
   Attempting to use a combination of `this.media.pause()` and `this.media.play()` will not resume playback, nor will `seekTo(position)`. 
   
   Has anybody run into this? `seekTo` will work most of the time as expected, but can randomly trigger this permanent pause. Same goes for playback. It'll freeze 6 minutes in, or 20+ minutes into a track. The only thing that snaps this out of it is to release or empty the media object, and then re initialize it `(media = new Media(/* relevant arguments */)`. A potential workaround could be to detect that playback is true, but duration is not moving, then quickly reset each time (putting all of this into an interval). That hardly solves the problem unfortunately. Any help would be monumentally useful. Thank you for even looking! 
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   My code is straightforward. It's Cordova, using Vue:
   Data property `media: null as any`
   
   Then when a track is selected:
   ```
   this.media = new Media(this.player.mediaUrl, undefined, this.cordovaMediaError, this.cordovaStatusChange)
   ```
   Then using `this.media.pause(),` `this.media.play()`, and `this.seekTo(position)` upon selecting the play/pause button or html scrubber.
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you experiencing the issue? -->
   This happens on an emulator and a physical device (iPhone SE, iOS 14.7.1).
   
   
   ### Version information
   Cordova 10.0.0
   ```
   ...
   "dependencies": {
       "@auth0/cordova": "^0.4.2",
       "auth0-js": "~>9.13.2",
       "cordova-plugin-androidx": "^3.0.0",
       "cordova-plugin-androidx-adapter": "^1.1.3",
       "cordova-plugin-background-mode": "^0.7.3",
       "cordova-plugin-customurlscheme": "~5.0.0",
       "cordova-plugin-device": "^2.0.3",
       "cordova-plugin-enable-cleartext-traffic": "^2.1.0",
       "cordova-plugin-file": "^6.0.2",
       "cordova-plugin-inappbrowser": "^3.2.0",
       "cordova-plugin-media": "^5.0.3",
       "cordova-plugin-music-controls2": "git+https://github.com/ghenry22/cordova-plugin-music-controls2.git",
       "cordova-plugin-safariviewcontroller": "~1.6.0",
       "cordova-plugin-x-toast": "^2.7.2"
     },
     "devDependencies": {
       "babel-cli": "^6.26.0",
       "babel-core": "^6.26.3",
       "babel-loader": "^8.0.6",
       "babel-preset-es2015": "^6.24.1",
       "babel-preset-stage-0": "^6.24.1",
       "cordova": "^10.0.0",
       "cordova-android": "^10.0.1",
       "cordova-ios": "^6.2.0",
       "expose-loader": "^0.7.5",
       "webpack": "^4.35.3",
       "webpack-cli": "^3.3.5"
     },
     "cordova": {
       "plugins": {
         "cordova-plugin-enable-cleartext-traffic": {},
         "cordova-plugin-media": {},
         "cordova-plugin-inappbrowser": {},
         "cordova-plugin-safariviewcontroller": {},
         "cordova-plugin-customurlscheme": {
           "URL_SCHEME": "com.dramafy.app",
           "ANDROID_SCHEME": "com.dramafy.app",
           "ANDROID_HOST": "dramafy.us.auth0.com",
           "ANDROID_PATHPREFIX": "/cordova/com.dramafy.app/callback"
         },
         "cordova-plugin-androidx": {},
         "cordova-plugin-androidx-adapter": {},
         "cordova-plugin-music-controls2": {},
         "cordova-plugin-background-mode": {},
         "cordova-plugin-x-toast": {},
         "cordova-plugin-whitelist": {}
       },
       "platforms": [
         "android",
         "ios"
       ]
     }
   ```
   MacOS Big Sur 11.4
   Xcode
   Not using Ionic
   
   <!-- 
   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.
   -->
   
   
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x] I searched for existing GitHub issues
   - [x] I updated all Cordova tooling to most recent version
   - [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.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

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



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


[GitHub] [cordova-plugin-media] pslyman commented on issue #309: [iOS] Stalled Playback

Posted by GitBox <gi...@apache.org>.
pslyman commented on issue #309:
URL: https://github.com/apache/cordova-plugin-media/issues/309#issuecomment-894581513


   Follow-up question as I've done more exploration of the issue. Are there certain codecs that are or aren't supported by the plugin, or more specifically in context, the AVPlayer? 


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

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

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



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


[GitHub] [cordova-plugin-media] pslyman commented on issue #309: [iOS] Stalled Playback

Posted by GitBox <gi...@apache.org>.
pslyman commented on issue #309:
URL: https://github.com/apache/cordova-plugin-media/issues/309#issuecomment-890450357


   Addendum, from Xcode:
   ```
   THREAD WARNING: ['Media'] took '10.185303' ms. Plugin should use a background thread.
   ```
   Doesn't seem completely relevant, but worth mentioning. 


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

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

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



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


[GitHub] [cordova-plugin-media] pslyman closed issue #309: [iOS] Stalled Playback

Posted by GitBox <gi...@apache.org>.
pslyman closed issue #309:
URL: https://github.com/apache/cordova-plugin-media/issues/309


   


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

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

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



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


[GitHub] [cordova-plugin-media] pslyman commented on issue #309: [iOS] Stalled Playback

Posted by GitBox <gi...@apache.org>.
pslyman commented on issue #309:
URL: https://github.com/apache/cordova-plugin-media/issues/309#issuecomment-894412976


   I should add that our URL source uses a redirect. We have a simple URL, the server redirects to the actual location (much longer URL) and starts the streaming. This work flawlessly for most audio files. On each platform it looks like this:
   
   ![image](https://user-images.githubusercontent.com/22920382/128549735-4106c81f-918d-4379-9cce-43d30c67e643.png)
   
   And the `Sizes` tab in the Network page in Safari for the second Network call, the redirect:
   (I'll add that it marks this as range bytes 0-1)
   ![image](https://user-images.githubusercontent.com/22920382/128549906-72f82b62-6107-4361-8dde-22d2785e7747.png)
   
   The one in red has 0 bytes transfer, but I assume it's something to do with `206 partial content`. This has `Range: bytes=0-31403535`. 
   
   It looks the same no matter the file, just there are a few that refuse to play on iOS. 


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

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

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



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


[GitHub] [cordova-plugin-media] pslyman commented on issue #309: [iOS] Stalled Playback

Posted by GitBox <gi...@apache.org>.
pslyman commented on issue #309:
URL: https://github.com/apache/cordova-plugin-media/issues/309#issuecomment-918643703


   Final (probably) update:
   Testing the audio files on a different server worked perfectly. My team ended up speaking with the streaming provider about the issue and they got to work. A week or two later, the issue was resolved. For some reason they had an issue delivering their audio streams, and we weren't the only ones with this problem.
   
   I'll mark this as Closed. If anybody else has this issue and finds this Github issue, best of luck and I hope something in here is helpful to you. Most likely it's an issue with your audio provider or server. Best of luck. 


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

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

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



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


[GitHub] [cordova-plugin-media] ghenry22 commented on issue #309: [iOS] Stalled Playback

Posted by GitBox <gi...@apache.org>.
ghenry22 commented on issue #309:
URL: https://github.com/apache/cordova-plugin-media/issues/309#issuecomment-893954379


   That thread warning isn't relevant to this, most of the key operations on the media plugin already use a background thread, a few don't but it won't be related to your issue.
   
   I use the media plugin extensively and I haven't come across this to date, if this is a live stream or something that doesn't really have a set duration then maybe it's something to do with that as all my use is with streams with a known end.
   
   Media playback stall would seem to indicate that it is not able to get data from the server fast enough, can you try a couple of different sources?


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

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

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



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


[GitHub] [cordova-plugin-media] pslyman edited a comment on issue #309: [iOS] Stalled Playback

Posted by GitBox <gi...@apache.org>.
pslyman edited a comment on issue #309:
URL: https://github.com/apache/cordova-plugin-media/issues/309#issuecomment-894408559


   Thanks for the reply! 
   
   The app in question is one that has one server source, but many streaming audio tracks, kind of like a music streaming service. I am using remote files, including `206 Partial Content` delivery in parts as it should It works perfectly on web, and Android. I've tried many other audio files and they play fine, with a rare few refusing to play at all. Each track has a defined length, and is set in size.
   
   To add detail to this, I've been able to narrow down some things. First, if I do `media.pause()` before `media.seekTo()`, then resume after, seeking won't give me that `playback stalled` error. Additionally, after giving my media object a URL, if I put `media.play()` on a timeout of 150-300ms, it won't give me that error either. However, this seems to be only showing a symptom of the problem. 
   
   For instance I'll get `1: MEDIA_ERR_ABORTED` `AVPlayerItem cannot service a seek request with a completion handler until its status is AVPlayerItemStatusReadyToPlay`. That happens if I try to use a scrubber after trying to load the track, revealing that AVPlayer rather doesn't have enough buffer, or something else. The track in question is about 5-6 minutes, and 7-8MB in size. This only shows up if the track refused to play to begin with. 
   
   Is there a way to tell the plugin to wait for `AVPlayerItemStatusReadyToPlay`, or should it already? Will the player refuse to play a track if it's too big (bitrate)? I'm not sure if there's a timeout on waiting for a buffer, or a hard limit on size for AVPlayer. I'm having a difficult time narrowing this down. 


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

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

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



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


[GitHub] [cordova-plugin-media] pslyman commented on issue #309: [iOS] Stalled Playback

Posted by GitBox <gi...@apache.org>.
pslyman commented on issue #309:
URL: https://github.com/apache/cordova-plugin-media/issues/309#issuecomment-894408559


   The app in question is one that has one server source, but many streaming audio tracks, kind of like a music streaming service. I am using remote files, including `206 Partial Content` delivery in parts as it should It works perfectly on web, and Android. I've tried many other audio files and they play fine, with a rare few refusing to play at all. 
   
   To add detail to this, I've been able to narrow down some things. First, if I do `media.pause()` before `media.seekTo()`, then resume after, seeking won't give me that `playback stalled` error. Additionally, after giving my media object a URL, if I put `media.play()` on a timeout of 150-300ms, it won't give me that error either. However, this seems to be only showing a symptom of the problem. 
   
   For instance I'll get `1: MEDIA_ERR_ABORTED` `AVPlayerItem cannot service a seek request with a completion handler until its status is AVPlayerItemStatusReadyToPlay`. That happens if I try to use a scrubber after trying to load the track, revealing that AVPlayer rather doesn't have enough buffer, or something else. The track in question is about 5-6 minutes, and 7-8MB in size. This only shows up if the track refused to play to begin with. 
   
   Is there a way to tell the plugin to wait for `AVPlayerItemStatusReadyToPlay`, or should it already? Will the player refuse to play a track if it's too big (bitrate)? I'm not sure if there's a timeout on waiting for a buffer, or a hard limit on size for AVPlayer. I'm having a difficult time narrowing this down. 


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

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

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



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


[GitHub] [cordova-plugin-media] pslyman commented on issue #309: [iOS] Stalled Playback

Posted by GitBox <gi...@apache.org>.
pslyman commented on issue #309:
URL: https://github.com/apache/cordova-plugin-media/issues/309#issuecomment-895718553


   Update:
   Tried re-encoding the MP3 (from LAME1000 to something else) and putting it on a different server. Worked brilliantly. However, this doesn't explain how Android works so well. By this point though, I've noticed it's not perfect on Android either. The experience is significantly better, but sometimes will freeze up (without console output from what I can tell) when using `seekTo()` too far into the track (plus 20 minutes). Kbps has been less than 320 for each file, which isn't different from the original files. 
   
   What I've somewhat concluded, mostly just a theory, is if a server is dishing out partial content too slowly or has too many hiccups when trying to get further into the track, AVPlayer will timeout and decide to "stall playback". My secondary theory is that old buffers aren't getting cleared, or AVPlayer is not requesting enough buffer, or isn't willing to play audio before a certain amount of buffer is loaded. In short, a buffer issue. 
   
   I don't have the language expertise to make any fixes to this plugin via a pull request. My suggestion to anyone who has the same problem:
   1. Test re-encoding your audio files using a different codec. 
   2. Try putting them on a different server, test the results. 
   3. Timeouts everywhere, see what works. You can't subscribe to `AVPlayerItemStatusReadyToPlay`, so this is all you got. Granted, AVPlayer should be handling this in the first place, or I wouldn't have this issue. 
   4. Switch to HTML5 audio handling, and throw in the [Cordova plugin background mode](https://github.com/katzer/cordova-plugin-background-mode)
   
   Good luck. 


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

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

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



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