phhusson / ims

GNU General Public License v2.0
101 stars 13 forks source link

Crash on call initiation #18

Open skr4n opened 1 month ago

skr4n commented 1 month ago

Greetings! I have built the apk and installed it on a Galaxy M21 (Exynos 9611) from source as per README and #16. It is running LineageOS 21 GSI Feb build. The carrier is Airtel India. Network type has been set to "LTE only" via *#*#4636#*#* in an attempt to force the usage of VoLTE as otherwise, the phone simply resorts to making 2G calls. WiFi is enabled.

Issue:

After setting up the Ims apk as instructed, initiating a call does ring the receiver's end, but upon accepting the call, the caller's end drops the call with a popup "Ims has stopped working", indicating a crash. The call stays on the other end with silence. Receiving a call does the same, clicking "Answer" results in an immediate call drop with the popup "Ims has stopped working", the call stays on the other end with silence.

I have collected the log using adb logcat -b radio. Log: log.txt Crash Log: crash.txt

Thank you for your work.

martinetd commented 1 month ago

Thanks for the report!

This is a bit silly but if you have a crash it won't be in the radio log, you'll also need to get a regular adb logcat -- we'll probably need to look at -b radio as well to check what went wrong with the parsing but having both would be super helpful.

Note the parsing for calls is pretty hard-coded (I still haven't taken time to fix it for my own provider...), so any refactoring there will probably help with crashes

skr4n commented 1 month ago

Sorry, I just realized that! Here is the output of adb logcat -b crash: crash.log This comes despite having manually allowed all permissions (including Mic and Phone) in app settings.

martinetd commented 1 month ago

Thanks!

startRecording() called on an uninitialized AudioRecord could be a permission problem (it's the first thing that pops up when searching for this message), but it could apparently be anything else that made the AudioRecord() call fail (e.g. frequency or something not supported on this device)... It's probably possible to check if the call worked or not but I don't know if we can get it to spill out why (maybe in a debug logcat?)

I'm not too familiar with this but hopefully @phhusson will know better.

skr4n commented 1 month ago

In SipHandler.kt,

val audioRecord = AudioRecord(MediaRecorder.AudioSource.VOICE_COMMUNICATION, 8000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, minBufferSize)

Replacing VOICE_COMMUNICATION with VOICE_CALL (along with adding the necessary permission in manifest) does fix the crash and the call goes through.

New Issues

  1. The calls work only when WiFi is enabled. Disabling it and attempting to make a call just ends the call on spot. Attempting to dial from a different device says the device is busy.
  2. The receiver does not receive my audio, the mic indicator too doesn't show up. This might be unrelated to IMS, as it happens with Signal calls too, i.e, receiver does not hear anything, no mic indicator. Strangely, Whatsapp calls don't have this audio issue. This audio issue happens only on Android 14 GSIs for my device (including TrebleDroid AOSP builds).

Logs

crash.log radio.log

phhusson commented 1 month ago

@skr4n sorry if it sounds stupid, but did you check that the app has the right to use the microphone in the settings?

skr4n commented 1 month ago

Yes, I have manually enabled the Microphone permission in the app settings and set it to "Allow only while using the app" since before posting the issue.

martinetd commented 1 month ago

Might be worth trying to allow not just while using the app? If the call does go through the ims framework, the app in use won't be ims but Phone or whatever you're dialing from, so I'm not sure android will consider phhims to be "in use"

phhusson commented 1 month ago

Yeah I agree with @martinetd but I've seen cases where Android doesn't let the user do that -_-' I'll dig at how we're supposed to do that and why does it work in some cases and some not...

skr4n commented 1 month ago

The available options were "Allow only while in use", "Ask every time" and "Don't allow" for Microphone. Besides, there is a "Phone" permission, which was set to "Allow" by default and greyed out with the text "Device requires this permission to operate". I had also ensured that the Battery Optimization is disabled (set to "Unoptimized") for Ims throughout my testing. So far I have seen the option "Allow all the time" only for the Location permission in a few apps... not sure if Microphone permission has an equivalent.