ubports / ubuntu-touch

Ubuntu Touch's issue inbox is now migrated to GitLab.
https://gitlab.com/ubports/ubuntu-touch
1.28k stars 110 forks source link

Audio playback in music app and podbird is choppy #1375

Closed mr-growl closed 2 years ago

mr-growl commented 4 years ago

Phone: Nexus 5 (hammerhead) Build: 2020-W07/2

TO REPRODUCE: play an mp3 file in the music app (something at least 30 seconds long ought to work)

EXPECTED: in ota 11 audio playback was very smooth, as you'd expect.

ACTUAL: currently the audio plays back but there are frequent pops, like it's having trouble keeping up. I first noticed this in podbird after getting the ota 12 RC update. I tried it while streaming the podcast, after downloading the podcast and then tried the music app and experience the problem in each situation.

It is very noticable but the audio is still understandable.

UniversalSuperBox commented 4 years ago

I notice this on the Xperia X (suzu) as well.

mr-growl commented 4 years ago

Tested 2020-W10 on nexus 5 and audio playback is once again beautiful and smooth in music app and podbird

mr-growl commented 4 years ago

Spoke too soon. after a few days it started getting choppy again. A reboot cleaned it up again, though.

Flohack74 commented 4 years ago

Give us some more context, are you using wired headphones, bluetooth or loudspeaker? Because that makes a huge difference for what path the sound is travelling and also how people can test this if they can confirm it.

mr-growl commented 4 years ago

I use headphones when listening to music or podcasts (regular, wired ear buds... nothing fancy).

Typically I turn on my phone and leave it running until something goes wrong days or weeks). The last reboot was with the update to 2020-W10 thursday. Audio was working fine that day and the next day as well. I did not try playing anything over the weekend (2 days) and when I tried again on monday it was choppy again but a reboot fixed it.

In that time I did not make or receive any phone calls. I sent and received a few texts. I used the morph browser, dekko, the skype web app, sailbook and activity tracker (with the shell script to enable gps tracking when the screen is off). I'll take a look at "top" next time it happens so see if anything stands out.

The only other things i can think of that stand out are that I only use wireless charging with this phone and that after the update to 2020-W07/2 I tried plugging in my hdmi adapter to see if convergence was working (it did not work). After the 2020-W10 update I didn't try the hdmi adapter till Saturday. If I were looking for a pattern I'd say that the problem seems to happen after trying convergence. BUT, I just tried the hdmi adapter again and it still doesn't do anything convergence-ish but the music is still playing smoothly.

wdehoog commented 4 years ago

On OPO I sometimes experience something similar. A track starts to play ok but becomes choppy after a while. This stops when I wake up the phone (plays ok) but immediately continues (becomes choppy) when I turn off the display. I need to reboot to get rid of this situation.

While audio is choppy syslog is flooded with:

Apr 13 11:28:16 ubuntu-phablet kernel: [  140.965711] PM: suspend entry 2020-04-13 09:28:16.801736046 UTC
Apr 13 11:28:16 ubuntu-phablet kernel: [  140.965736] PM: Syncing filesystems ... done.
Apr 13 11:28:16 ubuntu-phablet kernel: [  140.992943] Freezing user space processes ...
Apr 13 11:28:16 ubuntu-phablet kernel: [  141.008575] Freezing of user space  aborted
Apr 13 11:28:16 ubuntu-phablet kernel: [  141.008807]
Apr 13 11:28:16 ubuntu-phablet kernel: [  141.008825] Restarting tasks ... done.
Apr 13 11:28:16 ubuntu-phablet kernel: [  141.027298] PM: suspend exit 2020-04-13 09:28:16.863311804 UTC
Apr 13 11:28:16 ubuntu-phablet kernel: [  141.035559] PM: suspend entry 2020-04-13 09:28:16.871569964 UTC
Apr 13 11:28:16 ubuntu-phablet kernel: [  141.035567] PM: Syncing filesystems ... done.
fredldotme commented 4 years ago

Same with Xperia X. If there things can get choppy during the device being suspended then it might be due to the global wake lock being removed since a few months. The wakelock issue itself has been fixed with a kernel downgrade. In that case media-hub needs fixing to keep acquiring a wake lock on behalf of the app. Cloud Music seems to be plagued by the same bug. This PR is supposed to change handling in this area: https://github.com/ubports/media-hub/pull/8

If someone is interested in testing, please use the PRs built debian packages, choosing the architecture of the device: https://ci.ubports.com/job/ubports/job/media-hub/view/change-requests/job/PR-8/

wget them, dpkg -i them, sudo reboot.

wdehoog commented 4 years ago

This PR is supposed to change handling in this area: ubports/media-hub#8

I doubt it will help. This PR is only fixing the problem where media-hub does not acquire a new wakelock when playing the next track of a playlist of a suspended app. (It releases the wakelock when a track is finished.)

fredldotme commented 4 years ago

Sorry @wdehoog I missed you posting here as well, might have asked you directly then.

Thanks for the info. In that case, maybe refcounting the connected clients should be implemented, then the wake lock is held until no client is connected to media-hub anymore, which should happen when one deletes all QtMultimedia-based QMediaPlayer and associated VideoOutput objects, since that's the backbone of the QML implementation to. But on the other hand we would need proper testing and making sure it not only fixes apps (like Cloud Music) but also doesn't regress in other areas.

KamoCode commented 4 years ago

Hi, since the last weekend with the update to the Ubuntu touch Version 78 I have the same problem with my FP2. The sound switches on and of when the display is turned off. I observed the issue with the apps music, morph and alarm clock. A phone call and other functions like timer (not the sound) or messengers do not seem to be affected. A reboot/restart, change between speaker and headphones have no effect. Furthermore I tried to restart the background suspension of an app via UT Tweak Tool, but it had no influence if it was on or off in Tweak. With other words the Tweak switch doesn't work for that apps. The most interesting thin is that the sound doesn't stop when the phone is powered by USB. In the moment were the power supply is disconnected and the device is in battery mode, the problem start again. In my opinion it could be some kind of energy saving function.

fredldotme commented 3 years ago

Should be fixed by: https://github.com/fredldotme/device-kernel-loire/commit/84d9466cc10cc869b3a19086208cf4c6c59ef9b0 On that device we're not relying on the firmware for powering off CPUs anymore.

skowalczyk commented 2 years ago

I have the same issue on Pixel 3a, screen needs to be on to play music smoothly. Unfortunately ncspot breaks after that and only restart of that program helps. "Music" resumes smooth playback after I turn screen on and the same for "Futify". No change after connecting to power.

Phone: Pixel 3a Build: 2022-W22, channel: RC, everything up to date Ubuntu touch: it shows version 50

fredldotme commented 2 years ago

It's indeed weird that the Pixel 3a exposes these issues, but plausible considering it supports opportunistic autosuspend.

media-hub (and apps not going through it for multimedia purposes) needs to be made aware of properly taking wake locks once and for all.

fredldotme commented 2 years ago

Found the reason for it happening on the Pixel 3a and fixed it, tomorrow's devel build should contain the fix.

skowalczyk commented 2 years ago

Plays smoothly with UB ver 51, updated today and no issues so far.