chenxiaolong / BCR

A Basic Call Recorder for rooted Android devices
GNU General Public License v3.0
1.75k stars 113 forks source link

Failed to record call #195

Open effectively0 opened 1 year ago

effectively0 commented 1 year ago

I think it only occurs when answering calls received when screen is off. Using the latest version of the app. This is a new phone I've recently started using. Stock ROM with root. I've uploaded the failed oga file as a zip because Github only allows certain formats (like BCR ;-) ) Screenshot_Error Screenshot About Phone _in_REDACTED.log.txt _in_REDACTED.zip

chenxiaolong commented 1 year ago

It looks like the ROM is failing to open the call audio stream:

12-11 12:44:55.228 30364 31775 E AudioRecord: start(2672): status -38
12-11 12:44:55.228 30364 31775 D AudioRecord: start(2672): return status -38

I don't know what the -38 error code is. It doesn't exist in AOSP, so it might be something custom that Realme added.

This is not something that BCR can work around because the issue is in the audio driver built into the ROM. The only suggestion I have is to try all of the different sample rate options to see if that helps. The sample rate is the only option in BCR that affects the audio driver.

I think it only occurs when answering calls received when screen is off.

Just a random thought: Does this affect the regular microphone too (eg. does a voice recorder break when the screen is off)? Even though call audio and microphone audio are handled by different drivers, both pass through the same "microphone" permissions in Android. I wonder if the ROM has some privacy feature that's blocking access when the screen is off.

effectively0 commented 1 year ago

Just a random thought: Does this affect the regular microphone too (eg. does a voice recorder break when the screen is off)?

I just tried and it does not affect third party, non-call recording apps. I also have a version of Axet's Voice Recorder App, which works fine from di72nn github repo. I'll see if sample rates change anything.

effectively0 commented 1 year ago

I found this post, which references a solution to the same error code for android audio recording, but I'm not savvy enough to understand if its relevant. https://stackoverflow.com/questions/28204693/audiorecord-start-error-status-38

chenxiaolong commented 1 year ago

That link is a nice find. I've never encountered a device where the buffer size caused an issue, but let's test that out.

Can you give this build a try and upload the log? BCR-1.26.r9.g4e2ee2c-debug.zip

BCR normally uses a large buffer size: 6 times the minimum. This significantly reduces the chance that the audio cuts out if the CPU usage or disk usage suddenly spikes. Maybe your device doesn't like the large buffer (but I don't know why this would only happen if the screen is off...).

This test build will make BCR try a bunch of buffer sizes: 6x, 4x, 2x, and 1x. If it still fails, then I don't think the issue is related to https://stackoverflow.com/questions/28204693/audiorecord-start-error-status-38. 1x is supposed to work on every device.

EDIT: Dumb question: is there any other call recorder running at the same time as BCR? (any built into the ROM?) Apparently, some devices also report error -38 if two apps try to access the call audio at the same time.

effectively0 commented 1 year ago

Dumb question: is there any other call recorder running at the same time as BCR? (any built into the ROM?) Apparently, some devices also report error -38 if two apps try to access the call audio at the same time

Not a dumb question. Yes there is also the Axet Call Recorder (lets call it ACR) Magisk module I installed that runs simultaneously. I forgot to explicitly mention this (sorry!) and didn't think much of it as both apps work simultaneously unless I'm answering a call. (I keep 2 as I'm paranoid about one malfunctioning).

Now that you've reminded me, I did some tests and found that answering incoming calls while the screens is unlocked can reproduce the issue, so it seems to be incoming calls, not the lockscreen itself. I looked at those 129 Byte oga files and they are all incoming calls only. I also tried 10 outgoing calls and none failed. Disabling ACR also seems to fix the issue entirely.

The bug doesn't always occur either; of the 13 incoming calls I received today, only 4 failed to record (even after setting output format from 16kHz back to default yesterday). All 13 recorded successfully on the other app, so it doesn't seem like only one can work at a time.

The 1.26r9 debug doesn't work at all, even for outgoing calls and when I disable ACR. No log or failed 129 Byte oga files generated, even when changing output directory to and from default. It gives me a popup message asking me to clear history instead of the notification bar error. Clearing history does nothing.

I looked at the recording settings for ACR and Recording Source option is set to "Auto (default)", with options for Voice Line, Mic, System Default, VoIP, Voice Recognition, Camcorder". I thought perhaps ACR sometimes auto selects in such a way that interferes with BCR, but manually setting that option to Voice Line doesn't help BCR and the issue is still intermittent.

Thanks for putting so much effort into this.

chenxiaolong commented 1 year ago

Disabling ACR also seems to fix the issue entirely.

Just to confirm, when ACR is disabled, then BCR consistently works, even for incoming calls?

It gives me a popup message asking me to clear history instead of the notification bar error. Clearing history does nothing.

Hmm, I've never heard of this. BCR doesn't have any code that mentions the word "history". I'm not sure where that would be coming from.

In any case, it's probably not worth testing that build. Based on what you described so far, I doubt buffer size is the issue.

EDIT: Oh wait, you're on a Realme device. Did you have to do the workaround where you manually extract the .apk and install it? That might be related.

I thought perhaps ACR sometimes auto selects in such a way that interferes with BCR, but manually setting that option to Voice Line doesn't help BCR and the issue is still intermittent.

If ACR is set to Voice Line and both apps are running at the same time, does ACR consistently work while BCR does not? (Voice Line is also the audio stream that BCR uses.) I'm curious if ACR was also failing but would fall back to another source in auto mode.


EDIT 2: Please give this build a try: BCR-1.26.r9.g7bd8c41-debug.zip Just to make sure this bug isn't a timing related issue, this debug build will attempt to initialize the audio device up to 5 times (with a 200ms delay in betwwen).

You may need to uninstall the current version from Magisk, reboot, uninstall BCR from Android's settings, and then install the debug version.

effectively0 commented 1 year ago

Just to confirm, when ACR is disabled, then BCR consistently works, even for incoming calls?

Yes, BCR release build works in all cases while ACR is disabled.

Hmm, I've never heard of this. BCR doesn't have any code that mentions the word "history". I'm not sure where that would be coming from.

Maybe a Realme/Android thing. Here is a screenshot in case. Screenshot_2022-

In any case, it's probably not worth testing that build. Based on what you described so far, I doubt buffer size is the issue.

EDIT: Oh wait, you're on a Realme device. Did you have to do the workaround where you manually extract the .apk and install it? That might be related.

Yes. I completely forgot about that since I updated from 1.22 to 1.25 without having to do that. I'll try that on this new debug build if needed.

If ACR is set to Voice Line and both apps are running at the same time, does ACR consistently work while BCR does not? (Voice Line is also the audio stream that BCR uses.) I'm curious if ACR was also failing but would fall back to another source in auto mode.

I've had ACR set to Voice Line since that last post and the incoming call recordings still always work on ACR and intermittently fail on BCR.

EDIT 2: Please give this build a try: BCR-1.26.r9.g7bd8c41-debug.zip Just to make sure this bug isn't a timing related issue, this debug build will attempt to initialize the audio device up to 5 times (with a 200ms delay in betwwen).

You may need to uninstall the current version from Magisk, reboot, uninstall BCR from Android's settings, and then install the debug version.

Will do and report back, thanks.

EDIT: I uninstalled BCR via Magisk and upon reboot, there was no BCR app to uninstall from Android. Magisk installed the debug build, then installed app-debug.apk, rebooted and enabled all the permissions in app to find that it has the exact same issue as the previous debug build (BCR never generates recordings or log files and the Clear history popup sometimes occurs, even with ACR disabled. ACR still works while BCR is enabled). I uninstalled BCR via Magisk this time and the apk remained after reboot as non-system app this time. Uninstalled that, rebooted and installed the 1.26 release. I noticed that having debug mode enabled causes BCR 1.2.6 to generate no log or recording files. I uninstalled 1.26 and reinstalled 1.25 to find that debug mode can generate logs and recordings.

Now that I think of it, not installing the apk along with the Magisk zip was irrelevant when I tried the previous debug build because I confirmed the existence of the app data directory when I tried manually switching the Output directory.

chenxiaolong commented 1 year ago

I'm currently on vacation until the end of the year, but I'll take a look at your reply when I'm back.

Happy holidays!

dianid105 commented 1 year ago

Screenshot_20221218-151105 Screenshot_20221218-151338

В настоящее время я в отпуске до конца года, но я посмотрю на ваш ответ, когда вернусь.

Счастливых праздников!

Здравствуйте,тоже такая ошибка,не записывает.

chenxiaolong commented 1 year ago

EDIT: I uninstalled BCR via Magisk and upon reboot, there was no BCR app to uninstall from Android. Magisk installed the debug build, then installed app-debug.apk, rebooted and enabled all the permissions in app to find that it has the exact same issue as the previous debug build (BCR never generates recordings or log files and the Clear history popup sometimes occurs, even with ACR disabled. ACR still works while BCR is enabled). I uninstalled BCR via Magisk this time and the apk remained after reboot as non-system app this time. Uninstalled that, rebooted and installed the 1.26 release. I noticed that having debug mode enabled causes BCR 1.2.6 to generate no log or recording files. I uninstalled 1.26 and reinstalled 1.25 to find that debug mode can generate logs and recordings.

Thanks for testing this, especially note about 1.25+debugmode working. I suspect BCR may be silently crashing when logging is enabled due to a bug in 1.26's output filename customization feature. That would explain why both 1.26+debugmode and the two debug builds are broken (debug builds force enable debugmode logging). Repeated crashes might be what's triggering Realme's error messages too.

I'll investigate and likely post a new debug build here later.

chenxiaolong commented 1 year ago

Please give this new debug build a try: BCR-1.27.r2.g8c1b5c2-debug.zip

(1.27 and newer should hopefully fix the weird issues you've been encountering with 1.26+debugmode and debug builds)

effectively0 commented 1 year ago

Hi, I'm glad you took a break and wasn't expecting you back so soon. With this build, those earlier crash messages no longer occur and BCR is now generating files and logs. It now cannot generate recordings when output directory is customised (Internal Memory/Call Recorder). It generates 129B oga files like the original bug, a log file (attached) and a notification that cannot be tapped to open the app (attached). This problem occurs independently of ACR being enabled/disabled. It now consistently records incoming calls simultaneously with ACR so long as the default directory is used, so the original bug seems to have been fixed...I'm impressed that you were able to diagnose the issue without a log file. 202212.log.txt 202212.zip IMG_202212 failure notification

chenxiaolong commented 1 year ago

Glad to hear that the new debug build helps with the original issue.

I'm kind of baffled why changing the output directory would make a difference. BCR always records to the default internal directory first and the moves the file when the call is complete.

Unfortunately, looking at the log file, everything seems to be normal. At 2022-12-28 00:41:04.802, BCR started recording because Android reported that the call was active:

12-28 00:41:04.749 29475 29475 D RecorderInCallService: handleStateChange: Call [id: TC@18, state: ACTIVE, details: [id: TC@18, pa: ComponentInfo{com.android.phone/com.android.services.telephony.TelephonyConnectionService}, ***, UserHandle{0}, 1,SlotId = 1, hdl: tel:**********, hdlPres: 1, videoState: Audio Only, caps: [Capabilities: CAPABILITY_HOLD CAPABILITY_SUPPORT_HOLD CAPABILITY_MUTE CAPABILITY_SUPPORTS_VT_LOCAL_RX CAPABILITY_SUPPORTS_VT_LOCAL_TX CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL], props: [Properties: PROPERTY_HIGH_DEF_AUDIO]]], null, 4
12-28 00:41:04.802 29475 29623 I RecorderThread/2287: Recording thread started

and then at 2022-12-28 00:41:04.852 (50 milliseconds later), BCR stopped recording because Android reported that the call disconnected:

12-28 00:41:04.852 29475 29475 D RecorderInCallService: handleStateChange: Call [id: TC@18, state: DISCONNECTED, details: [id: TC@18, pa: ComponentInfo{com.android.phone/com.android.services.telephony.TelephonyConnectionService}, ***, UserHandle{0}, 1,SlotId = 1, hdl: tel:**********, hdlPres: 1, videoState: Audio Only, caps: [Capabilities: CAPABILITY_HOLD CAPABILITY_SUPPORT_HOLD CAPABILITY_MUTE CAPABILITY_SUPPORTS_VT_LOCAL_RX CAPABILITY_SUPPORTS_VT_LOCAL_TX CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL], props: [Properties: PROPERTY_HIGH_DEF_AUDIO]]], 7, 7
12-28 00:41:04.852 29475 29475 D RecorderThread/2287: Requested cancellation
effectively0 commented 1 year ago

Ok I spoke too soon. I thought the problem was fixed after answering 10 calls without issue, but just now I answered a call from the lockscreen on th2 1.27 debug build which failed to record.

dhrubo66 commented 1 year ago

Hi, I just found this app yesterday and loving it! I'm also facing the same issue mentioned here, the recording fails randomly with this message:

The recording failed in an internal Android component (android.media.MediaCodec.native_queuelnputBuff er). This device or firmware might not support call recording. Error Oxe

I also had axet installed, completely removed it, still recording failing randomly. This mostly happens fir incoming calls. In the last 24h, 2 of 14 outgoing calls and 5 of 8 incoming calls failed to record.

I'm on a Pixel based custom ROM (PixelOS) based on Android 13. BCR v1.30 flashed via Magisk.

Screenshot_20230201-102212_Niagara Launcher~2

bolltzain commented 1 year ago

For me it says successfully recorded but the file is not playable (blank).

chenxiaolong commented 1 year ago

For me it says successfully recorded but the file is not playable (blank).

Please create a new issue for this and attach the logs for the call (long press BCR's version number to enable debug mode and then make a call--BCR will write a .log file to the output directory).