flutter_sound: [HELP]: flutter_sound audio package conflicts
Hi
Hope you’re well; iOS specific (problem doesnt occur on android), anytime i use another package that uses audio, flutter_sound will cause the following crash, is there any known workarounds? As soon as audio is called from any other package e.g. flutter_tts (i’ve tested several), while trying to openRecorder i will get this error and the app will immediately crash,
Thanks in advance!
*** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: IsFormatSampleRateAndChannelCountValid(format)'
*** First throw call stack:
(0x181002d3c 0x19837c6a8 0x1810cc5bc 0x1dca7eea0 0x1dcaec9a0 0x1dcad4358 0x1dcb57224 0x1dcb3b828 0x1036a4464 0x1036a4c84 0x1036a32b8 0x10258f384 0x1025907f8 0x10a36a75c 0x109ea3cf8 0x10a231bb4 0x10a1591c0 0x10a15cf24 0x18101706c 0x180fa13d8 0x180f9c06c 0x180f7bf44 0x180f8ee1c 0x1a13399a0 0x1837c2b90 0x18355816c 0x102313a20 0x102c8c250)
libc++abi: terminating with uncaught exception of type NSException
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x00000001bb1369e8 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
-> 0x1bb1369e8 <+8>: b.lo 0x1bb136a04 ; <+36>
0x1bb1369ec <+12>: stp x29, x30, [sp, #-0x10]!
0x1bb1369f0 <+16>: mov x29, sp
0x1bb1369f4 <+20>: bl 0x1bb132670 ; cerror_nocancel
Target 0: (Runner) stopped.
Lost connection to device.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 32
@tan-yaka, @quickratio, others,
you are my friends, my only friends. What happens to my mother is horrible. She is 94y old.
I feel better when I know that I have friends all around the earth
I do not really know what Flutter Sound users like about this product. Myself, what I appreciate on this project is the possibility to manage Audio Streams. I think that Flutter Sound is the only Flutter plugin doing that.
But managing audio streams on Flutter Sound is far from perfect. There are many issues around this feature. Taudio will be a complete rewrite of Audio Streams. Of couse I am sure that you cannot wait several months for Taudio. So I will try to do some maintenance on Flutter Sound.
I just would like that you do not discourage and that you will be one of the first Taudio user.
@quickratio we had a requirement to recognise some weird drug names (most of which I couldn’t even pronounce!) and at the time MS STT was the only service that allowed us to train the speech model to recognise them using actual audio + transcriptions, and it worked really well. I know some of the other STT services now allow for this kind of training but we have invested a lot of time in perfecting our training method and amassed a lot of training data. I agree the Google STT API is far superior to the on device service. I’ve looked at other services like AWS Transcribe and found that to be the most difficult to implement and poorest performing in terms of accuracy. I’m going to be looking at some the smaller outfits offering STT like Speechly and Deepgram soon.
Laroux, you’re a bona fide f**king legend! I love you hahaha, seriously. How do you even figure this stuff out?
I hope someday we can work together on something, when i launch (hopefully soon, it is in beta!) i’ll shoot you a link, i’d be honoured if you had a look and gave feedback, after all, you’re part of it! 😃 (do you have an email i can communicate to you with, if you’re interested i can show you my project).
Also do you mind if i share this in other threads, as i know others had the exact same problem.
Thanks again! ❤️
@quickratio :
1. TL;DR : Restore a correctAudio Session before starting the recorder
A correct fix for your issue is :
2. Long version
On iOS, each App has its own Audio Session, but unfortunately, there is only just one audio-session for each running App. iOS is just a piece of bullshit. Because of this uniqueness, we get many compatibility issues when an App wants to use several packages which does not cooperate.
On Flutter Sound 8.x, we tried to manage ourself the Audio Sessions. It was convenient and was fine most of the time. But because of this management, Flutter Sound was badly compatible with others plugin. What happened was that each Plugin tried to fight for doing Session management.
The good way to fix this incompatibility, was to remove from Flutter Sound everything about Audio Session management, and rely on a federating manager (e.g. Audio-Session). It is what we did in FS 9.x
Everything will work correctly if no Audio plugins do Audio Session management, and if everybody rely on the federator : Audio-Session plugin. Actually I know two plugin which are good citizen and do not play with audio sessions
But many others plugin continue to try to manage the audio-sessions themselves. To solve that, you will need to to restore a correct audio session before startRecorder() (i.e. a session correct for doing a recording).
A crash is a terrible thing and is not good. A fix could be that FS checks that the session is correct and set itself a correct Session if necessary. But we will have again the same problems as in 8.x.
Another fix could be to check that the session is correct and throw an exception if not. I think that it is would be good and that is what I am going to do in 9.1.8
My crash was just because I forgot to put Recorder permission inside Runner/info.plist
I am going to try to reproduce your crash, now.