element-x-android icon indicating copy to clipboard operation
element-x-android copied to clipboard

EC: Add PoC for native audio output selector

Open jmartinesp opened this issue 7 months ago • 4 comments

Content

Motivation and context

Screenshots / GIFs

Tests

  • Step 1
  • Step 2
  • Step ...

Tested devices

  • [ ] Physical
  • [ ] Emulator
  • OS version(s):

Checklist

  • [ ] Changes have been tested on an Android device or Android emulator with API 24
  • [ ] UI change has been tested on both light and dark themes
  • [ ] Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • [ ] Pull request is based on the develop branch
  • [ ] Pull request title will be used in the release note, it clearly define what will change for the user
  • [ ] Pull request includes screenshots or videos if containing UI changes
  • [ ] You've made a self review of your PR

jmartinesp avatar Apr 30 '25 08:04 jmartinesp

:iphone: Scan the QR code below to install the build (arm64 only) for this PR. QR code If you can't scan the QR code you can install the build via this link: https://i.diawi.com/85waVz

github-actions[bot] avatar Apr 30 '25 09:04 github-actions[bot]

Codecov Report

Attention: Patch coverage is 18.91892% with 150 lines in your changes missing coverage. Please review.

Project coverage is 80.31%. Comparing base (56c9083) to head (d996cf2). Report is 14 commits behind head on develop.

Files with missing lines Patch % Lines
...id/features/call/impl/utils/WebViewAudioManager.kt 16.46% 136 Missing and 1 partial :warning:
...nt/android/features/call/impl/ui/CallScreenView.kt 58.33% 4 Missing and 1 partial :warning:
...droid/features/call/impl/ui/ElementCallActivity.kt 0.00% 4 Missing :warning:
...call/impl/utils/WebViewWidgetMessageInterceptor.kt 25.00% 3 Missing :warning:
...x/impl/widget/DefaultCallWidgetSettingsProvider.kt 0.00% 1 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4663      +/-   ##
===========================================
- Coverage    80.47%   80.31%   -0.16%     
===========================================
  Files         2140     2140              
  Lines        56756    56887     +131     
  Branches      7110     7150      +40     
===========================================
+ Hits         45672    45688      +16     
- Misses        8649     8765     +116     
+ Partials      2435     2434       -1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Apr 30 '25 09:04 codecov[bot]

After https://github.com/element-hq/element-x-android/pull/4743 this should now be ready to review.

jmartinesp avatar May 30 '25 08:05 jmartinesp

I have tested this and I am loosing the audio output when selecting Default (Built-in speaker).

Actually it was due to the fact that this is not the same volume mapping. For earpiece, the In-call volume is used, for Default, this is the Media volume. I am not sure if we can improve this?

bmarty avatar Jun 02 '25 12:06 bmarty

Actually it was due to the fact that this is not the same volume mapping. For earpiece, the In-call volume is used, for Default, this is the Media volume. I am not sure if we can improve this?

Oh, that's tricky. I'm not sure if we can make they use the same volume rocker or have some other way to make this transition seamless..

jmartinesp avatar Jun 02 '25 12:06 jmartinesp

But it seems that the audio input (in EX) was not working. I could not hear any voice coming to Element Web (sound alert was working so this is not a volume/mute problem on the browser)

Did you have video output or was that also failing? I've had one call this morning where the encryption keys exchange seemed to fail and that resulted in the 2 users seeing each other as present in the call but no video or audio getting through to the other.

jmartinesp avatar Jun 02 '25 13:06 jmartinesp

I have tested it again and this is the status for a call with EW and EX and EW does not render incoming video nor audio. The other side is working (EX render video and play audio)

bmarty avatar Jun 02 '25 13:06 bmarty

I have tested it again and this is the status for a call with EW and EX and EW does not render incoming video nor audio. The other side is working (EX render video and play audio)

Could you check you don't have set a custom Element Call URL? On EW you can use/devtools for that.

Actually it was due to the fact that this is not the same volume mapping. For earpiece, the In-call volume is used, for Default, this is the Media volume. I am not sure if we can improve this?

So I have good news and bad news after checking other apps and how they handle this issue:

  • The good news is I've found a way to make the audio use always the 'in call' stream and it would simplify the code.
  • The bad news is it's based on always using the deprecated APIs (the < API 12 we already have in place in this PR), which I'd rather not use and could be removed in the not-so-far future.

I'll check if there's any alternative to this, but I'm not really hopeful...

jmartinesp avatar Jun 02 '25 15:06 jmartinesp

I have not set any custom url on EW. For the volume I think it is acceptable if it's an OS limitation... But can be misleading for user (like me) thinking that the audio is not working when switching the output. There is maybe a way to read the volume level and warn the user that the volume is probably too low (I think I have seen other apps doing that, a long time ago, I do not remember which one).

bmarty avatar Jun 02 '25 15:06 bmarty

@bmarty could you retry with the latest changes?

jmartinesp avatar Jun 03 '25 09:06 jmartinesp

The latest changes should fix the issue with the audio for the speaker initially not following the right volume rocker, but now we need https://github.com/element-hq/element-call/pull/3309.

jmartinesp avatar Jun 03 '25 13:06 jmartinesp

The latest changes should fix the issue with the audio for the speaker initially not following the right volume rocker, but now we need element-hq/element-call#3309.

Rebased after upgrading the Element Call version in https://github.com/element-hq/element-x-android/pull/4832, which contains the changes needed to fix the audio for the device selected by default.

jmartinesp avatar Jun 06 '25 06:06 jmartinesp