Clementine icon indicating copy to clipboard operation
Clementine copied to clipboard

When using Subsonic support, Clementine only sees a small random subset of albums

Open njsmith opened this issue 4 years ago • 8 comments

Before posting

Please follow the steps below and check the boxes with [x] once you did the step.

  • [x] I checked the issue tracker for similar issues
  • [x] I checked the changelog if the issue is already resolved
  • [x] I tried the latest Clementine build from here

System information

Please provide information about your system and the version of Clementine used.

  • Operating System: Ubuntu 19.10
  • Clementine version: the version in the Ubuntu repos, and also 1.4.0rc1-167-gb0c92ae78 (= current HEAD)

Expected behaviour / actual behaviour

I configured Clementine's Subsonic support to point to an Airsonic server running on my local network.

Expected behavior: Clementine would be able to see and play all of the albums on the Airsonic server.

Actual behavior: Clementine connects successfully, and lists and can play some of the albums, but most albums are mysteriously missing.

For example, Clementine only finds 5 artists under "A":

But in fact I have lots more than that. Here's a screenshot of the artists list from the "Ultrasonic" Android app, pointing at the exact same Airsonic server. Notice that there are way more than 5, and they can't even all fit on the screen:

AFAICT, this is happening at the album level: if an album is there, then all of its songs are there and playable. But lots of albums are missing. For example, if I expand "Ani DiFranco", then Clementine only shows 1 album by her, but there should be 4.

To double-check that the problem is really on Clementine's side, I also used wireshark to sniff the communications between Clementine and the Airsonic server, and the server is clearly informing Clementine about albums that are missing from Clementine's display:

      <album id="779" name="The Definitive Collection (Disc 1)" artist="Abba" artistId="431" songCount="20" duration="4302" created="2002-03-10T06:14:43.000Z"/>
      <album id="780" name="The Definitive Collection (Disc 2)" artist="Abba" artistId="431" songCount="17" duration="4556" created="2002-03-10T02:53:51.000Z"/>

njsmith avatar Apr 13 '20 06:04 njsmith

Hmm, on further investigation, it appears that Clementine is truncating the album list sent by the server. It does multiple HTTP requests to the /rest/getAlbumList2.view?...&type=alphabeticalByName&size=500&offset=... endpoint, to fetch the first 500 albums, then the second 500 albums, etc. It does correctly fetch all of the pages. (In my case, I have less than 1000 albums, so this requires 3 requests, where the last request returns an empty response.) But the actual albums that eventually show up in the UI are:

  • The first 132 albums returned in the first page of results
  • The first 4 albums returned in the second page of results

njsmith avatar Apr 13 '20 07:04 njsmith

Ah-hah, found the issue. In the metadata that Airsonic is returning, a few of my albums have a mangled genre field, with the literal value Text=".";:

      <album id="105" name="Out Of The Blue" artist="Electric Light Orchestra" artistId="75" songCount="17" duration="4238" created="2010-08-09T00:38:12.000Z" genre="Text=&quot;.&quot;; "/>

I have no idea why the genre field was set to this weird value, but I guess it doesn't matter that much.

Clementine does not handle this gracefully at all. As soon as it sees an <album> tag with the weird genre field, then it stops parsing the album list entirely.

I think the issue is here, in the loop Clementine uses to scan the <album> tags:

https://github.com/clementine-player/Clementine/blob/b0c92ae7846874144b003fed0f3c29383d5635cb/src/internet/subsonic/subsonicservice.cpp#L482

If we look at the docs, they say that readNextStartElement returns false "when the end element was reached, or when an error occurred" (my emphasis).

So I guess Qt's XML parser gives an error when it sees the attribute genre="Text=&quot;.&quot;;"? That's pretty weird; it looks like valid XML syntax to me. But if you look at that function, this seems to be the only way that Clementine could abort parsing an album list early, but then continue to fetch the next page of albums.

njsmith avatar Apr 13 '20 07:04 njsmith

As a workaround, I manually found the 3 offending albums inside Airsonic's web UI, and used its "Edit tags" function to set a more sensible genre. After doing this and restarting everything a few times, Clementine now appears to be able to see and play my whole library.

njsmith avatar Apr 13 '20 07:04 njsmith

If it is bailing there due to an XML error, then I think there's a bug in QXmlStreamReader. I think that's still well-formed XML. Which QT5 version is 19.10 using?

jbroadus avatar Apr 15 '20 03:04 jbroadus

Looks like it's:

Package: libqt5xml5
Version: 5.12.4+dfsg-4ubuntu1.1

njsmith avatar Apr 15 '20 04:04 njsmith

I don't see anything obviously broken in their code. They do use a proprietary parser generator, so there are likely some fun corner cases. https://github.com/qt/qtbase/tree/dev/src/corelib/serialization

It might be interesting to add your failing snippet to one of their test cases and see what it does.

jbroadus avatar Apr 16 '20 06:04 jbroadus

I have been able to confirm this happens on clementine 1.4, but not on 1.3.1

Johnny-Malizia avatar Aug 20 '20 15:08 Johnny-Malizia

This started to happen to me again after upgrading to to the latest version of Ubuntu with Clementine v. 1.4.0~rc1+git347-gfc4cb6fc7+dfsg-2 , only one album is loading from my library.

EDIT: I tried to edit the tags of the an apparently objectionable album, and now nothing loads.

joshp23 avatar Jan 04 '24 03:01 joshp23