[music-app] Trunk fails autopilot tests on jenkins

Bug #1350529 reported by Andrew Hayzen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Music App
Fix Released
High
Victor Thompson
mediascanner2
Fix Released
Undecided
Unassigned
mediascanner2 (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Trunk is failing autopilot tests on jenkins [0]

If you watch the failure videos you can see a blank album/artist/genre in the models which is causing the tests to fail. This is likely due to a change mediascanner2.

0 - http://91.189.93.70:8080/job/music-app-ci/965/console

Related branches

Andrew Hayzen (ahayzen)
summary: - Trunk fails autopilot tests
+ Trunk fails autopilot tests on jenkins
Revision history for this message
Andrew Hayzen (ahayzen) wrote : Re: Trunk fails autopilot tests on jenkins

Adding also affects mediascanner2, as the issue is likely to be there.

Andrew Hayzen (ahayzen)
summary: - Trunk fails autopilot tests on jenkins
+ [music-app] Trunk fails autopilot tests on jenkins
Revision history for this message
Victor Thompson (vthompson) wrote :

I don't understand yet what the app is seeing. But this shows up on the console when I access one of these items:

qml: Debug: Add track to queue: [object Object]
file:///opt/click.ubuntu.com/com.ubuntu.music/1.3.544/MusicNowPlaying.qml:570:31: Unable to assign [undefined] to QString
file:///opt/click.ubuntu.com/com.ubuntu.music/1.3.544/MusicNowPlaying.qml:582:31: Unable to assign [undefined] to QString
file:///opt/click.ubuntu.com/com.ubuntu.music/1.3.544/MusicNowPlaying.qml:594:31: Unable to assign [undefined] to QString
qml: Debug: Queue: Now has: 1 tracks
qml: Debug: MusicQueue update currentIndex:
qml: {"art":"image://albumart/artist=undefined&album=undefined"}

I've attached what these items look like, but I assume they are media files (pictures, etc) that are not music files.

David Planella (dpm)
Changed in music-app:
status: New → Triaged
importance: Undecided → High
Revision history for this message
James Henstridge (jamesh) wrote :

Does this come from one of the models provided by the mediascanner QML plugin?

The main change that was landed is that the data is loaded into its models asynchronously. So the the model is usable (and not blocking the UI) before all the data has been loaded.

I'm a bit confused by the art URI though: I wouldn't expect the mediascanner QML plugin to generate something like that unless you had an artist/album called undefined.

tags: added: lt-blocker lt-category-visible lt-prio-high
Revision history for this message
Andrew Hayzen (ahayzen) wrote :

@James

Yes these are models provided by the mediascanner QML plugin.

For the album art we generate it ourselves with something like
"image://albumart/artist=" + model.author + "&album=" + model.album

We appear to be getting an 'empty' item in the models (which has an undefined author/album etc) which is then causing the counts for the models to be incorrect for autopilot.

Then there looks to be a further issue where when the trackQueue is populated it ends up with all of the tracks having undefined metadata. This could be due to the get(i, role) not working correctly or something else going wrong.

Revision history for this message
James Henstridge (jamesh) wrote :

Looking at the code, the only way you'd get undefined here is when asking for a row > model.rowCount. Note that the models are all set up so they only grow while loading data: if you've got a valid index, it should remain valid while data streams in.

Also, the models already provide an "art" role that should give you a correctly formed art URI (you aren't encoding the artist and album names in the above, for instance).

I'll see if I can spot any other obvious culprits.

Revision history for this message
James Henstridge (jamesh) wrote :

So, just to be clear, the only way you can get an undefined value from reading model.author/album is this piece of code in the model's data() method:

    QVariant MediaFileModelBase::data(const QModelIndex &index, int role) const {
        if (index.row() < 0 || index.row() >= (ptrdiff_t)results.size()) {
            return QVariant();
        }

It also looks like the model attached to the MusicNowPlaying list view is not one of the ones from mediascanner but something custom to music-app.

To help with debugging, here is a brief rundown of how the asynchronous loading currently works:

* The model data is requested in a background thread, but actually added to the model within the main event loop thread, so each update should appear atomic to JavaScript.

* As we fill a model, we only append data while filling, so indexes into the model should be stable provided the model filters aren't changed. The rowCount property will always be consistent with the data currently held in the model.

* As before, changing any of the filter properties will reset the model (so any model indexes would be invalid). Since the changes happen asynchronously now, the model will not be filled as soon as the property change completes though.

Below are a few things I noticed while reading through the code that are probably not the cause of the bug, but might be worth fixing at some point:

1. in processFile() in music-app.qml, you're iterating through a model holding all the songs in order to find one with a matching file name. It would be more efficient to just call musicStore.lookup(filename)

2. If at all possible, use the "art" model role we provide as the artwork URI rather than constructing it again. Most cases where art URIs are constructed in the code look like they would be broken for artists or album names containing special characters. It might make it more obvious when you're reading invalid rows from the model too.

Revision history for this message
Andrew Hayzen (ahayzen) wrote :

@James

Ok i'll look at resolving those issues you have stated. Yes you are correct the model in the now playing page is custom, but this is just a collection of tracks from other models which are appended to the queue.

I've updated the latest image, and to me the issue looks like only the extra 'blank' items appearing in the models. I have created an example application [0] which is SongsModel and should show the title and filename of each track.

If you start it on the latest image (for me) I get two empty tracks and in the logs you can see the corresponding 'Unable to assign [undefined] to QString' for each blank item, all the items below these load correctly. I can only assume it is not filtering to only music and is listing video/pictures as well?

0 - lp:~andrew-hayzen/+junk/ms2-empty-models-example

Revision history for this message
Andrew Hayzen (ahayzen) wrote :

FYI if you run the branch I linked in the previous comment [0] it looks like this [1].

As you can see the first two list items are totally blank (they have no filename or title), and here is the trace of the app [2], you can see that they are infact undefined.

This shows the that issue is not the music-app but is something within the model itself (or we are missing a filter somewhere?)

@James any ideas whats going on?

1 - https://docs.google.com/file/d/0B3XynHVKfrvMOW5BOWV4Q2lieTg/edit
2 - http://pastebin.ubuntu.com/7955070/

Revision history for this message
James Henstridge (jamesh) wrote :

I'm still looking into this. From what I can see, the problem goes away if I get rid of the SortFilterModel wrapper. I'm still investigating to see what's going on.

Revision history for this message
James Henstridge (jamesh) wrote :

I think I've tracked down the bug. I'm just waiting for Jenkins to build me some ARM packages and will test it out on-device:

https://code.launchpad.net/~jamesh/mediascanner2/fix-insert-rows/+merge/229595

The code was obviously incorrect on a closer reading of the QAbstractItemModel documentation, and it seems to get Andrew's minimal test case to behave.

Revision history for this message
James Henstridge (jamesh) wrote :

Okay. I'm no longer seeing the "undefined" album on the main screen in music-app.

Revision history for this message
James Henstridge (jamesh) wrote :

Packages are in landing silo 11:

https://launchpad.net/~ci-train-ppa-service/+archive/ubuntu/landing-011

I'll run through the media scanner's test plan tomorrow so it can be landed, but I'd appreciate any extra testing in the mean time.

Revision history for this message
Victor Thompson (vthompson) wrote :

Thanks James, we've tested this out and it seems to work perfectly. We are experiencing an unrelated test failure in music-app's Autopilot tests. I think this is due to a toolkit change. A fix should be proposed shortly.

Changed in music-app:
assignee: nobody → Victor Thompson (vthompson)
status: Triaged → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package mediascanner2 - 0.102+14.10.20140805-0ubuntu1

---------------
mediascanner2 (0.102+14.10.20140805-0ubuntu1) utopic; urgency=low

  [ James Henstridge ]
  * Fix off by one error when appending new rows to QML models. (LP:
    #1350529)
 -- Ubuntu daily release <email address hidden> Tue, 05 Aug 2014 11:44:48 +0000

Changed in mediascanner2 (Ubuntu):
status: New → Fix Released
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

Fix committed into lp:music-app at revision 554, scheduled for release in music-app, milestone 1.0

Changed in music-app:
status: In Progress → Fix Committed
Changed in music-app:
status: Fix Committed → Fix Released
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Indeed 100% pass on image #177, thanks!

Changed in mediascanner2:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.