spotube icon indicating copy to clipboard operation
spotube copied to clipboard

Intermittent Distorted Audio

Open OfficialMuffin opened this issue 1 year ago โ€ข 22 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

When screen backlight times out and locks screen automatically and audio continues to play in tbe background, audio distorts at random times throughout. Even with other songs in the playlist. E.g. suddenly voices and instruments turn high pitched and back to normal.

Expected Behavior

Audio to play with no issues when screen timeout expires and phone locks automatically.

Steps to reproduce

  1. Play audio from playlist
  2. Wait for screen timeout to expire.
  3. Audio will then distort at random times

Operating System

Android (GrapheneOS)

Spotube version

3.0.0

Installation source

F-Droid (Android)

Additional information

GrapheneOS build version: TQ3A.230705.001.2023070500

OfficialMuffin avatar Jul 11 '23 17:07 OfficialMuffin

Sorry but v3.0.0 was never released on F-Droid ๐Ÿคจ

KRTirtho avatar Jul 21 '23 03:07 KRTirtho

Apologies, I did download the APK from the GitHub releases. Strangely, it doesnt seem to be having audio issues at the moment. Ill reopen this issue if it returns.

OfficialMuffin avatar Jul 23 '23 16:07 OfficialMuffin

Please re-open as I am having the exact same issue: audio is distorted when left playing in the background and the screen turns off.

I am using Spotube 3.1.1 from F-droid. I double checked the app battery settings and it is set to "unrestricted".

My OS is Android OSP 13 (GrapheneOS) on a Google Pixel 6 Pro.

hackerb9 avatar Sep 14 '23 05:09 hackerb9

Not sure if this is related to updating to Android 14 or not but updating to 3.2.0 seems to bring this issue back. 3.1.x was working fine for me until now.

Anyone else having the same issue?

OfficialMuffin avatar Oct 25 '23 19:10 OfficialMuffin

I just tried both 3.1.2 and 3.2.0 and neither works for me. After a minute of being idle, the sound starts glitching. The only "workaround" I've found is to run some other program that keeps the CPU from going into a low power state.

hackerb9 avatar Oct 28 '23 16:10 hackerb9

By the way, harmonoid does not have this problem on my phone.

hackerb9 avatar Oct 31 '23 17:10 hackerb9

I have this issue on a Pixel 6a / Android 14 using both the current version on the Google store (3.2.0) and the current version on F-Droid. For me, the distorted sound does not happen when using my bluetooth headphones, it happens when I am using the phone speaker.

jriano avatar Nov 02 '23 15:11 jriano

I have this issue on a Pixel 6a / Android 14

@jriano Are you running the Google version of Android or something like GrapheneOS?

hackerb9 avatar Nov 05 '23 02:11 hackerb9

I am using the Google version of Android.

On Sat, Nov 4, 2023, 22:19 hackerb9 @.***> wrote:

I have this issue on a Pixel 6a / Android 14

@jriano https://github.com/jriano Are you running the Google version of Android or something like GrapheneOS?

โ€” Reply to this email directly, view it on GitHub https://github.com/KRTirtho/spotube/issues/571#issuecomment-1793611061, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD364YSZT3DRCXVB33YUR3YC3ZSRAVCNFSM6AAAAAA2GLAH2OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJTGYYTCMBWGE . You are receiving this because you were mentioned.Message ID: @.***>

jriano avatar Nov 05 '23 13:11 jriano

I am using the Google version of Android.

Thanks. So now we know that the problem occurs on Pixel 6 devices regardless of OS.

Additionally, another app which uses the same Flutter library for playing sound (Harmonoid) does not have the same issue, so the bug is almost certainly in Spotube.

hackerb9 avatar Nov 12 '23 19:11 hackerb9

I have a same issue on those environments:

  • Galaxy Fold 3 5G / Android 13 / Samsung One UI 5.1
  • Galaxy Note 20 5G / Andrdid 13 / Samsung One UI 5.1

Both have a same version of Spotube (3.4.0) and installed via Google Play appstore, and battery optimization is off for the app.

Currently I'm listening music via Bluetooth earbud (Galaxy Buds 2 Pro) and maybe this can be a reason...?

I'm going to use the app via wired earphones today to find out whether wireless earphones makes the problem.

sappho192 avatar Jan 23 '24 02:01 sappho192

Strangely, I've noticed recently that this only happens without any Bluetooth devices connected, and audio is playing directly through the phones speakers.

Having tested audio on two bluetooth headsets for a couple hours, there has been no distorted audio through them. Almost like Bluetooth keeps the CPU awake or something like along the lines. Thats if the problem is the device being "CPU starved". See comment @ https://github.com/KRTirtho/spotube/issues/663#issuecomment-1718793706

OfficialMuffin avatar Jan 31 '24 09:01 OfficialMuffin

I am also experimenting intermittent distorted audio on my Pixel 6, running Android 14 (Official Build UQ1A.240105.002), specifically when playing content directly through the phone speakers (no distortions occur when using Bluetooth audio devices). I've tried to troubleshoot the issue, but unfortunately, I have been successful. Here's a list of what I've tried so far in case it can provide any insights for debugging:

  • Adjusted audio qualities to medium/low
  • Switched audio source to Piped or Jiosaavn
  • Granted unrestricted battery usage permissions to the app
  • Kept the app open, preventing the phone from going to sleep

martiperez avatar Feb 04 '24 22:02 martiperez

I looked into this issue and into Harmonoid as suggested by @hackerb9. Here's what I found. Please correct me on any inaccuracy.

Both Harmonoid and Spotube use ryanheise/audio_service, but that's only for the background service and lock screen visual. The audio stack are different, at least in Spotube 3.4.

  • Harmonoid uses just_audio which uses Google's ExoPlayer which seems to use AudioTrack.
  • Spotube uses media_kit which uses libmpv which appears to use OpenSL ES by default, but can be configured to use AudioTrack. I've seen some commented code in Spotube player related to just_audio, but not sure if it's a previous implementation or an upcoming transition (@KRTirtho ?).

Maybe we could detect available audio sinks from libmpv and offer the selection in the settings? I didn't look into that.

My change seems fairly safe as OpenSL ES is the fallback if AudioTrack is not available, but it would be nice if someone else with the issue could test on their device.

I'll post video of the issue and the fix when I can.

By the way, when the audio issue occurs, logcat gets spam with a bunch of: AOC aocd D F1:Irregular FIQ at 19074804: delta 4438 (lb: 4056, ub: 4136, FIQ delta: 341) I can't tell if the cpu is starved by so much logging output and that's what causing the issue of if the audio issue produces the output. Anyway, the relation between the 2 events are obvious when running logcat. I couldn't find any info on aoc, aocd or Irregular FIQ online.

olivier2 avatar Feb 08 '24 19:02 olivier2

Here are videos for reference. Sorry for the quality, the issue was not reproducible unless using the speaker

https://github.com/KRTirtho/spotube/assets/1408881/d97e4531-0528-4f23-90d6-b2653aa25451

https://github.com/KRTirtho/spotube/assets/1408881/838abc7b-87d3-401f-a77d-569ce1c39085

olivier2 avatar Feb 09 '24 18:02 olivier2

Sorry for the really late reply ๐Ÿ˜“

I've seen some commented code in Spotube player related to just_audio, but not sure if it's a previous implementation or an upcoming transition (@KRTirtho ?).

I used just_audio before, but the desktop support for it wasn't good enough. So I partially started using media_kit for Spotube and eventually media_kit was stable enough for Mobile too, and it generally works better now. (Initially, Spotube was in fact using mpv's IPC to play music in desktop through mpv_dart). So I removed just_audio for all platforms and currently have no plans to add it back

KRTirtho avatar Feb 24 '24 13:02 KRTirtho

The PR made by @olivier2 has been merged and should be available in nightly (10-20mins after this comment). Please test this out, and please let us know if it works now in this thread

KRTirtho avatar Feb 25 '24 16:02 KRTirtho

The PR made by @olivier2 has been merged and should be available in nightly (10-20mins after this comment). Please test this out, and please let us know if it works now in this thread

It's not working for me: only black screen after accepted music and audio files on Android 14 Pixel 6 Pro.

Thanks!!

mustard007 avatar Feb 25 '24 18:02 mustard007

It's not working for me: only black screen after accepted music and audio files on Android 14 Pixel 6 Pro.

I have the same with the nightly. Black screen after permission dialog box.

olivier2 avatar Feb 25 '24 19:02 olivier2

Didn't feel right to open an issue for a nightly build, so started this discussion with the content of the spotube log.

olivier2 avatar Feb 25 '24 19:02 olivier2

Hi, I've installed the latest nightly build (~ e6a20b5a1674b6af25121fafaefffa55d5557342 ) and it seems that this audio issue has gone so far in my environments:

  • Galaxy Fold 3 5G / Android 13
  • Galaxy Note 20 5G / Andrdid 13
  • Bluetooth earbud (Galaxy Buds 2 Pro)

Thank you @olivier2 so much!

~~But instead, I've met a new issue. Next track doesn't play after current song ends during the screen is off. If the app is running in foreground, next song plays well.~~ (Above cancelled issue seems to be resolved by disabling the battery optimization for this nightly app)

sappho192 avatar Feb 26 '24 06:02 sappho192

Hi, I've installed the latest nightly build (~ e6a20b5 ) and it seems that this audio issue has gone so far in my environments:

  • Galaxy Fold 3 5G / Android 13
  • Galaxy Note 20 5G / Andrdid 13
  • Bluetooth earbud (Galaxy Buds 2 Pro)

Thank you @olivier2 so much!

~But instead, I've met a new issue. Next track doesn't play after current song ends during the screen is off. If the app is running in foreground, next song plays well.~ (Above cancelled issue seems to be resolved by disabling the battery optimization for this nightly app)

Thanks and good job !!

Sound trouble also gone for me with this nightly. Pixel 6 Pro.

mustard007 avatar Feb 26 '24 14:02 mustard007

Closing it as it's fixed. Massive

Thanks

to @olivier2

KRTirtho avatar Mar 12 '24 14:03 KRTirtho