PixelExperience / android-issues

Issue tracker
95 stars 41 forks source link

Low media volume after notification #5128

Closed willianwrm closed 9 months ago

willianwrm commented 1 year ago

Build Date

PixelExperience_Plus_beckham-13.0-20230503-0955-OFFICIAL.zip

Device

beckham

Version

thirteen_plus

Describe the Bug

While playing music the volume goes low after a notification (as expected) but does not goes back to normal after some time as it should. The only way to make it back to normal is by closing the music player.

Video showing it happening. 2023_05_10_14_24_06.txt logcat, the telegram notification was received by 05-10 14:24:14.137

Some other devices such as miatoll and blueline did report this issue in the past.

Steps to Reproduce

Expected Behavior

The media volume should goes back to normal in a few seconds after a notification sound.

Possible Solution

Killing the media app does the trick but have to do it after every notification. Noticed that in TikTok this doesn't happen; the media volume goes low only for a few seconds (as expected).

pixelexperiencebot commented 1 year ago

Issue created! You can close at any time by commenting /close

willianwrm commented 1 year ago

@Merinorus, @NicoCardona, @nikhilmn01 and @Premudraya-Va are you still having such issue?

Merinorus commented 1 year ago

Yes, I could reproduce the problem when connected on Bluetooth headsets. 2023-05-04 official build.

jro1979oliver commented 1 year ago

Well, I'm doing test today and seems I managed to fix, on bt earphones no reduction of volumes

willianwrm commented 1 year ago

Well, I'm doing test today and seems I managed to fix, on bt earphones no reduction of volumes

I see you did push some changes on sdm660-common and beckham a few hours ago, can't wait to official build! Thanks a lot!

nikhilmn01 commented 1 year ago

Yes I'm still facing the same issue. I'm using 6th May release version installed on my OnePlus 7 Pro.

Steps to replicate the bug:

  1. Keep any media playing in music player.
  2. Receive a text message or any notification in ring mode with pixel default Eureka notification tone and observe how the volume reduces and never restores.

On Thu, May 11, 2023, 9:40 PM willianwrm @.***> wrote:

@Merinorus https://github.com/Merinorus, @NicoCardona https://github.com/NicoCardona, @nikhilmn01 https://github.com/nikhilmn01 and @Premudraya-Va https://github.com/Premudraya-Va are you still having such issue?

— Reply to this email directly, view it on GitHub https://github.com/PixelExperience/android-issues/issues/5128#issuecomment-1544278671, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVCJ3DGNOGVISYKR4USOPDDXFUFRHANCNFSM6AAAAAAX5BQ6MI . You are receiving this because you were mentioned.Message ID: @.***>

willianwrm commented 1 year ago

Thanks for the relese @jro1979oliver, did update to PixelExperience_Plus_beckham-13.0-20230512-1612-OFFICIAL.zip but the issue continues :'( Video: https://youtube.com/shorts/Jsylqm1ce0o Log: 2023_05_15_08_48_57.txt telegram notification at 05-15 08:49:13.699

The only thing that changed, regardless of volume, was the notification and alarm volumes, both are full no matter what value I try to select.

willianwrm commented 1 year ago

The first time I did notice this issue was in the release _PixelExperience_Plusbeckham-13.0-20230110-1147-OFFICIAL.zip, so it should be some change between november 8 through january 10.

So I did search for "FadeOutManager" in the _frameworkbase repository, did find this commit in december, by the log it shouldn't do anything wrong but the commit itself does change a lot of things...

I'm completely new to Android code but I'm very suspicious about the function line 305 of the file PlaybackActivityMonitor.java, the doNotLog is ignoring all events from the player, including mFadingManager.checkFade: in line 318 the method is abandoned if doNotLog is true and event is not _PLAYER_STATERELEASED, kind abrupt in my opinion.

willianwrm commented 1 year ago

Thanks again for the release! Updated to PixelExperience_Plus_beckham-13.0-20230518-1817-OFFICIAL.zip and it solved the issue but partially: Playing using default phone output works, notification sound does not lower the volume at all (ok). But playing through bluetooth continues the same problem... there is a fadeout and the volume does never goes back up.

Generated a new log: logcat.log In this log I did test first TikTok (working fine) and Spotify (buggy).

TikTok Notification at 05-18 17:52:04.384 05-18 17:52:04.892 AudioService.PlaybackActivityMonitor: ducking player piid:415 05-18 17:52:07.638 AudioService.PlaybackActivityMonitor: unducking piid:415 05-18 17:52:07.639 AudioService.FadeOutManager: unfadeOutUid()

Spotify Notification at 05-18 17:52:42.940 05-18 17:52:42.989 AudioService.PlaybackActivityMonitor: ducking player piid:439

and stopped there, no unducking player or unfadeOutUid() call. The problem seems to be a core one and not device specific.

jro1979oliver commented 1 year ago

Thanks again for the release! Updated to PixelExperience_Plus_beckham-13.0-20230518-1817-OFFICIAL.zip and it solved the issue but partially: Playing using default phone output works, notification sound does not lower the volume at all (ok). But playing through bluetooth continues the same problem... there is a fadeout and the volume does never goes back up.

Generated a new log: logcat.log In this log I did test first TikTok (working fine) and Spotify (buggy).

TikTok Notification at 05-18 17:52:04.384 05-18 17:52:04.892 AudioService.PlaybackActivityMonitor: ducking player piid:415 05-18 17:52:07.638 AudioService.PlaybackActivityMonitor: unducking piid:415 05-18 17:52:07.639 AudioService.FadeOutManager: unfadeOutUid()

Spotify Notification at 05-18 17:52:42.940 05-18 17:52:42.989 AudioService.PlaybackActivityMonitor: ducking player piid:439

and stopped there, no unducking player or unfadeOutUid() call. The problem seems to be a core one and not device specific.

Yeah, it's not a bug on device side and I did changes on source side to reach this results. Tested using YouTube and TikTok. I will be looking deeper for the bluetooth output issue

willianwrm commented 1 year ago

Did find where the problem is happening and a way around it: setting _Settings.System.MULTI_AUDIO_FOCUSENABLED to false did fix the problem.

Actually what I did was to force it's value in the services/core/java/com/android/server/audio/MediaFocusControl.java constructor, setting the mMultiAudioFocusEnabled to false after reading the setting.

The problem seems to be Spotify does not have the _AudioManager.AUDIOFOCUS_FLAGLOCK flag set, so besides is in the mMultiAudioFocusList it never get signaled back.

willianwrm commented 1 year ago

For who is having such issue you may fix it too by: 1 - prepare adb debug 2 - execute in cmd/terminal:

adb shell
settings put system multi_audio_focus_enabled 0
exit

And restart the phone.

if you want to undo just:

adb shell
settings put system multi_audio_focus_enabled 1
exit
Merinorus commented 1 year ago

The ADB command worked. You have no idea how long some people have been struggling with it. Thank you! Hope we'll make it into the source code to avoid people having to write this command.

Jorg3Lucas commented 9 months ago

Hello, I hope you are well, thanks for your feedback/report, we have ended support for Android 13. We hope you will be with us in the future to make the Android 14 experience as stable as possible.