-
Notifications
You must be signed in to change notification settings - Fork 822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Audioplayers fails on iOS after ~750 mp3s with AVPlayerItem.Status.failed #746
Comments
I have reproduced this with the example in this repo: https://github.com/mikeesouth/audioplayers/tree/issue-746 Note that it's a branch called issue-746 that is branched from 0.16.1. To reproduce the error, start the example and press any red play-button (there is one right at the start page). It will play a sound and overlap with the same sound again after 50ms so the sound output is quite annoying and "choppy", like a robot that has some kind of speech problem :) The red play button will play a small mp3 file (test.mp3) 2000 times. On iOS simulators, Android emulators and Android physical devices - this works just fine. On physical iOS devices, it stops playing sounds after about 700-750 times, that is after about 1 minute. When it stops playing sounds, the print output from the app is similar to this (note that lap 731 and 732 works just fine, 733 gets error AVPlayerItemStatus.failed and all the following calls get the same error):
Currently, on line 64/65 in one_time_audio_player.dart, I just have a delay of 50ms. By uncommenting line 65 ( Do you have any idea what's going on here @luanpotter ? I'm happy to submit a PR but I'm not sure why this is happening or how I can try to fix it. |
Pretty sure I'm experiencing the same memory leak as described here: #141 |
I'm experiencing a similar issue on Android that is a physical device (Huawei P9 lite). Some output from my log: |
I tried both and voicePlayerCache ??= AudioCache(fixedPlayer: voicePlayer); PS: is not reproducible on android emulator |
Any update on this issue? I'm getting the same error |
I'm getting the same error AVPlayerItem.Status.failed. |
As am I. Same error and similar circumstances. I have 36 Audioplayers. Error happens eventually and inconsistently. Same error code
|
Is this still a thing in |
Yes, I'm still getting the error in |
1.1.1 and iOS Then I cached the short audio players, the error gone. |
@dvishalakshan @DamonChen117 you may can reproduce it by modifying our example: https://github.com/bluefireteam/audioplayers/tree/main/packages/audioplayers/example You may want to debug and provide a fix, too. Thank you :D |
I'm using audioplayers in a production app. It works great but I just discovered a critical bug. After playing about 750 mp3 files, audioplayers keep throwing an error (AVPlayerItem.Status.failed) and no more sounds are played. This happens only on iOS and only on physical devices.
Full Description
This is a really strange bug (at least to me) and I'm not sure if I'm doing something wrong in my code but I do not think so. The code is working perfectly for Android and also perfectly for iOS for quite some time but after about 750 played mp3s, it crashes. It may of course be something else but I can reproduce this by playing any mp3 ~750 times in a loop. This is no matter if I create my own AudioPlayer or use AudioCache. It does not matter if the files are long (~10s or short ~1s). It doesn't matter if I'm in MEDIA_PLAYER mode or LOW_LATENCY mode. If I just loop the same sound for 2000 times it will crash after about 750 played mp3s.
I've tested with audioplayers 0.16.1 and 0.17.2, both have the same result.
Code to Reproduce
I've not been able to test this minimal reproducible example yet since I can only test it on a physical iOS device and I do not have an iOS device here right now. I will try it tomorrow and post the results. But this code should reproduce the bug. The minimal reproducible example would be to clone the example from this lib and change this code:
to
Please note that the delay maybe isn't necessary, I'm not sure. I've used 50ms delay in our app. Use 3 seconds or so to prevent overlap of the sound but I do not think it matters for reproducing the bug.
Log Errors
No errors really, except that the AudioPlayer sends an error with message "AVPlayerItem.Status.failed" through the onPlayerError stream of the AudioPlayer.
Platforms
This seems to be a bug specific for iOS, maybe MacOS as well but I have not tested that OS. I've tested iOS 12.x and 14.x, both have the same error. I've tested on iPad mini 2nd gen, iPad 6th gen, iPad 8th gen - all have the same error.
I've used Flutter stable 1.22.5 for all
The text was updated successfully, but these errors were encountered: