Bug 461299 - elisa: irrtating stutters when playing audio
Summary: elisa: irrtating stutters when playing audio
Status: RESOLVED FIXED
Alias: None
Product: Elisa
Classification: Applications
Component: general (show other bugs)
Version: 22.08.2
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Matthieu Gallien
URL:
Keywords:
: 466735 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-11-01 20:30 UTC by Roman Lebedev
Modified: 2023-11-09 20:53 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 23.04
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Lebedev 2022-11-01 20:30:05 UTC
Sometimes, when playing local audio files, regardless of system's load level,
the audio playback momentairly stops and then resumes, it takes maybe less than 1s.

This is happening on fully performance tuned Pipewire setup,
and pwtop does not show any issues on pipewire side.

I highly suspect elisa is simply running out of the input to play,
and stutters when fetching next chunk from disk.

Does elisa already have some kind of precaching system?
Would it be acceptable to simply fully prefetch the whole file
before playing, or is the filesize a concern? Something smarter,
like ensuring that N next seconds are always avaliable could be nice, too.
Comment 1 Roman Lebedev 2022-11-05 22:21:57 UTC
Posted minimal fix at https://invent.kde.org/multimedia/elisa/-/merge_requests/397
I don't know if this fully solves the problem for me, but if it does not,
the next step would be forcing the kernel to prefetch the whole file...
Comment 2 Nate Graham 2022-11-14 17:29:11 UTC
Git commit 7848ea003340ce1e7269e3fa96396eaf17e3e77d by Nate Graham, on behalf of Roman Lebedev.
Committed on 14/11/2022 at 17:29.
Pushed by ngraham into branch 'master'.

Set libvlc playback cache size to 10 seconds (#461299)

The most common use-case for Elisa is to start playing something, and let it play
without jumping around. libvlc defaults to 1 seconds of cache; let's increase it
to 10 seconds to cut down on the potential for audio stutters.
23.04

M  +7    -0    src/audiowrapper_libvlc.cpp

https://invent.kde.org/multimedia/elisa/commit/7848ea003340ce1e7269e3fa96396eaf17e3e77d
Comment 3 Aurélien COUDERC 2022-11-23 10:50:58 UTC
I’ve added the patch to the Debian package on top of 22.08.3 but it doesn’t solve the issue. It makes it less frequent but I still have occasional sound cuts on an otherwise idle modern machine.

I’ve not looked at the code but if the stutter is due to the playback directly waiting for the data to load from the disk, the correct solution is not to make the buffer bigger, it’s only going to make it less frequent.
Also loading complete files in memory is not the solution either. I have a couple of albums that are a single FLAC file of a couple hundres of MBs and it seems overkill to load these entirely into memory.

If the issue is really the playback buffer becoming empty, the real fix would be to ensure the prefetch is done in the background so the playback never ends up waiting for the data to be there.


Thanks for looking into this !
Comment 4 Roman Lebedev 2022-11-23 12:50:34 UTC
(In reply to Aurélien COUDERC from comment #3)
> I’ve added the patch to the Debian package on top of 22.08.3 but it doesn’t
> solve the issue. It makes it less frequent but I still have occasional sound
> cuts on an otherwise idle modern machine.
> 
> I’ve not looked at the code but if the stutter is due to the playback
> directly waiting for the data to load from the disk, the correct solution is
> not to make the buffer bigger, it’s only going to make it less frequent.
> Also loading complete files in memory is not the solution either. I have a
> couple of albums that are a single FLAC file of a couple hundres of MBs and
> it seems overkill to load these entirely into memory.
> 
> If the issue is really the playback buffer becoming empty, the real fix
> would be to ensure the prefetch is done in the background so the playback
> never ends up waiting for the data to be there.
> 
> 
> Thanks for looking into this !

I have not analysed *all* the remaining issues i heard, but at least some of them were artifacts in the audio itself.
Are you sure that is not the case for you?
Comment 5 Aurélien COUDERC 2022-11-23 14:58:12 UTC
After more testing it seems to be limited to some files and the stuttering is reproducible for the same file and timestamp with all VLC-based apps.

Mplayer doesn’t choke on the same files.

I will do more testing and report but I guess from an Elisa standpoint you can close the bug.


Thanks !
Comment 6 Nate Graham 2022-11-23 15:25:53 UTC
Sounds like a libvlc issue, perhaps.
Comment 7 Roman Lebedev 2022-11-23 20:53:11 UTC
(In reply to Nate Graham from comment #6)
> Sounds like a libvlc issue, perhaps.

You know what, why don't we just switch to libvlc backend?
Comment 8 Roman Lebedev 2022-11-23 20:53:32 UTC
(In reply to Roman Lebedev from comment #7)
> (In reply to Nate Graham from comment #6)
> > Sounds like a libvlc issue, perhaps.
> 
> You know what, why don't we just switch to libvlc backend?

Err. Of course, i meant libmpv.
Comment 9 Roman Lebedev 2022-11-25 23:05:45 UTC
(In reply to Roman Lebedev from comment #8)
> (In reply to Roman Lebedev from comment #7)
> > (In reply to Nate Graham from comment #6)
> > > Sounds like a libvlc issue, perhaps.
> > 
> > You know what, why don't we just switch to libvlc backend?
> 
> Err. Of course, i meant libmpv.

https://invent.kde.org/multimedia/elisa/-/merge_requests/400
Testing welcomed.
Comment 10 Aurélien COUDERC 2022-12-04 21:17:40 UTC
For reference there’s an upstream bug referencing the FLAC stuttering issue in VLC/libvlc here :
https://code.videolan.org/videolan/vlc/-/issues/27454

And a fix :
https://code.videolan.org/videolan/vlc/-/merge_requests/2918/diffs

That we’ve applied to the Debian sources on top of 3.0.18 with a minor fix here :
https://salsa.debian.org/multimedia-team/vlc/-/commit/c5289e84e17421c1e40ef9f0953b6c0f96a20cb2
Comment 11 Nate Graham 2022-12-05 18:37:56 UTC
Oh great!

Roman, can you try to patch your VLC sources (if your distro isn't already offering that fix, of course) and see if it fixes the issue?
Comment 12 Nate Graham 2023-03-06 22:38:39 UTC
*** Bug 466735 has been marked as a duplicate of this bug. ***
Comment 13 sunwebrw 2023-11-09 20:48:42 UTC
I have the same issue. Version 23.08.2
Mpv plays flac well, Elisa stutters(sometimes way too often).
Comment 14 sunwebrw 2023-11-09 20:53:56 UTC
I forgot to update vlc, now everything is good, sorry.