Canardoux / flutter_sound

Flutter plugin for sound. Audio recorder and player.
Mozilla Public License 2.0
874 stars 569 forks source link

[BUG]: app crashes when trying to start recording during a phone call #776

Open amitrotner opened 3 years ago

amitrotner commented 3 years ago

Flutter Sound Version :


Severity


Platforms you faced the error


Describe the bug App crashes when trying to start recording during a phone call.

To Reproduce Steps to reproduce the behavior:

  1. Answer a phone call
  2. Go to app and start recording
  3. App crashes

Logs!!!!

(This is very important. Most of the time we cannot do anything if we do not have information on your bug). To activate the logs, you must instantiate your modules with the Log Level set to Level.debug :

flutter: \^[[38;5;4m2021-09-29 07:45:00.127378Z General, I: GetPermission called for 7, got PermissionStatus.granted<…>
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   new FlutterSoundRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:155:13)
flutter: │ #1   AudioRecorder._initRecorder (package:tw_app/UI/Mobile/Widgets/General/AudioRecorder.dart:49:22)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 ctor: FlutterSoundRecorder()
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   FlutterSoundRecorder.openAudioSession (package:flutter_sound/public/flutter_sound_recorder.dart:393:13)
flutter: │ #1   AudioRecorder._initRecorder (package:tw_app/UI/Mobile/Widgets/General/AudioRecorder.dart:50:27)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 FS:---> openAudioSession
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   FlutterSoundRecorder._openAudioSession (package:flutter_sound/public/flutter_sound_recorder.dart:413:13)
flutter: │ #1   FlutterSoundRecorder.openAudioSession.<anonymous closure> (package:flutter_sound/public/flutter_sound_recorder.dart:395:17)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 ---> openAudioSession
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   FlutterSoundRecorder.openRecorderCompleted (package:flutter_sound/public/flutter_sound_recorder.dart:186:13)
flutter: │ #1   MethodChannelFlutterSoundRecorder.channelMethodCallHandler (package:flutter_sound_platform_interface/method_channel_flutter_sound_recorder.dart:98:22)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 ---> openRecorderCompleted: true
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   FlutterSoundRecorder.openRecorderCompleted (package:flutter_sound/public/flutter_sound_recorder.dart:197:13)
flutter: │ #1   MethodChannelFlutterSoundRecorder.channelMethodCallHandler (package:flutter_sound_platform_interface/method_channel_flutter_sound_recorder.dart:98:22)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 <--- openRecorderCompleted: true
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   FlutterSoundRecorder._openAudioSession (package:flutter_sound/public/flutter_sound_recorder.dart:449:13)
flutter: │ #1   <asynchronous suspension>
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 <--- openAudioSession
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   FlutterSoundRecorder.openAudioSession (package:flutter_sound/public/flutter_sound_recorder.dart:403:13)
flutter: │ #1   <asynchronous suspension>
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 FS:<--- openAudioSession
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: \^[[38;5;3m2021-09-29 07:45:00.179158Z General, W: AudioRecorder: _audioPath = /var/mobile/Containers/Data/Application/4AE43902-DB5A-406F-9C51-E98FB7CE1C45/Library/Caches/1632901500013.pcm<…>
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   FlutterSoundRecorder.setSubscriptionDuration (package:flutter_sound/public/flutter_sound_recorder.dart:561:13)
flutter: │ #1   AudioRecorder.startAudioRecording (package:tw_app/UI/Mobile/Widgets/General/AudioRecorder.dart:125:27)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 FS:---> setSubscriptionDuration
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   FlutterSoundRecorder.setSubscriptionDuration (package:flutter_sound/public/flutter_sound_recorder.dart:568:13)
flutter: │ #1   <asynchronous suspension>
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 FS:<--- setSubscriptionDuration
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   FlutterSoundRecorder.startRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:635:13)
flutter: │ #1   AudioRecorder.startAudioRecording (package:tw_app/UI/Mobile/Widgets/General/AudioRecorder.dart:140:29)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 FS:---> startRecorder
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   FlutterSoundRecorder._startRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:659:13)
flutter: │ #1   FlutterSoundRecorder.startRecorder.<anonymous closure> (package:flutter_sound/public/flutter_sound_recorder.dart:637:13)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 FS:---> _startRecorder.
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[aurioc] AURemoteIO.cpp:1097:Initialize: failed: 561017449 (enable 1, outf< 2 ch,      0 Hz, Float32, non-inter> inf< 2 ch,      0 Hz, Float32, non-inter>)
[avae]            AVAEInternal.h:76    required condition is false: [AVAEGraphNode.mm:823:CreateRecordingTap: (IsFormatSampleRateAndChannelCountValid(format))]
*** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: IsFormatSampleRateAndChannelCountValid(format)'
*** First throw call stack:
(0x1903ff25c 0x1a4194480 0x19030cc98 0x1d998cb80 0x1d99f085c 0x1d99d7dd0 0x1d9a5c110 0x1d9a3d410 0x1048e0844 0x1048e1064 0x1048df59c 0x1008acb4c 0x1008ae068 0x104d7aa60 0x104a8bd7c 0x104d95070 0x104d2f1d4 0x104d319fc 0x19037f0a8 0x19037eca8 0x19037e17c 0x1903784b4 0x1903777d0 0x1a6ab9570 0x192ca42d0 0x192ca984c 0x10015b6a0 0x190056140)
libc++abi: terminating with uncaught exception of type NSException
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001bc1ed7b0 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
->  0x1bc1ed7b0 <+8>:  b.lo   0x1bc1ed7cc               ; <+36>
    0x1bc1ed7b4 <+12>: stp    x29, x30, [sp, #-0x10]!
    0x1bc1ed7b8 <+16>: mov    x29, sp
    0x1bc1ed7bc <+20>: bl     0x1bc1ca1fc               ; cerror_nocancel
Target 0: (Runner) stopped.
Lost connection to device.

See this


Larpoux commented 3 years ago

@amitrotner , Thank you for your Problem Report. It is clear and correctly filled. I like such Problem Reports.

Do you record to a File or to a Stream ?

amitrotner commented 3 years ago

@amitrotner , Thank you for your Problem Report. It is clear and correctly filled. I like such Problem Reports.

Do you record to a File or to a Stream ?

Thanks. I record to a Stream

Larpoux commented 3 years ago

OK. I think that there is some bugs when recording Streams. Actually we support only PCM - INTEGER16, but the default PCM format on iOS is FLOAT32.

I am almost sure that the problem is because the iOS device switched to FLOAT32.

I am currently busy working on Tau Sound 9.0. This new branch will support many different PCM formats :

So your Problem Report is really interesting for me, to help me debug this stuff.

kiwicmc commented 3 years ago

No, this is an instance of the phone call having control of the mic, and flutter_sound is swallowing exceptions on FlutterSoundPlayer.openAudioSession amongst others.

In our app we use FlutterSound to record, and also SpeechToText simultaneously. If we are in a Zoom call, and then start our app that uses these plugins, this message appears in the log:

[plugin] Error starting listen: The operation couldn’t be completed. (OSStatus error 561017449.)

ios error 561017449 is defined in AVAudioSession.h: AVAudioSessionErrorInsufficientPriority = '!pri', / 0x21707269, 561017449 / and is described as "The app was not allowed to set the audio category because another app (Phone, etc.) is controlling it."

Larpoux commented 3 years ago

Yes, @kiwicmc , Your shared info with your App are interesting.

I can understand that the microphone cannot belong to two App at the same time. But having a phone call during the run of Flutter Sound is something that can happen very often, and the App must be able to handle this thing. (The App is the only people knowing what to do in this case).

Probably, Flutter Sound should trigger an explicit (and well documented) exception, instead of falling into un-understandable traps. If someone can do a Pull Request for that, it would be great : I actually have much work on τ Sound 9.0, and I have no time to spend on Flutter Sound 8.4

github-actions[bot] commented 10 months ago

This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.

NSLogZfRee commented 9 months ago

https://blog.csdn.net/Morris_/article/details/110160354