SongsModel.status is not set as MediaStatus.Ready if rowCount is zero

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

Bug Description

Currently the Music app is attempting to integrate Content Hub support with the help of the streaming models provided by Mediascanner [1]. One of the changes we making is to properly detect when the models are loading vs there being no music on the device. Right now we are catching the onFilled signal to set the model to a 'populated' state. However, this also means that when new media is found (either by the user copying songs over, or because a song is imported via content hub) the rowCount is reset and we briefly detect that there is no music.

We are trying to make this check detect the empty state 1) allSongsModel.rowCount === 0 and 2) SongsModel.status === ModelStatus.Ready. However SongsModel.status never seems to be in the Ready state when rowCount is zero.

[1] https://code.launchpad.net/~andrew-hayzen/music-app/content-hub-dest-support/+merge/231037

Tags: rtm14

Related branches

summary: - SongsModel.status never seems to be set as MediaStatus.Ready
+ SongsModel.status is not set as MediaStatus.Ready if rowCount is zero
description: updated
Bill Filler (bfiller)
Changed in mediascanner2:
importance: Undecided → High
Changed in music-app:
importance: Undecided → High
tags: added: rtm14
Revision history for this message
James Henstridge (jamesh) wrote :

Can you provide some code that demonstrates the bug?

I put together this simple program to try and reproduce the problem, but came up blank. When I run it, I get the following output:

    qml: Status changed to 1, count = 0
    qml: Status changed to 0, count = 5784

So the status property's notify signal is correctly firing for the Loading and Ready state changes. When I press enter, which updates the model to filter for artist "no such artist", I get some more output:

    qml: Status changed to 1, count = 0
    qml: Status changed to 0, count = 0

Since both the row count and status properties have notify signals, the bottom text component in the UI also updates to say "empty" at this point.

Changed in mediascanner2:
status: New → Incomplete
Revision history for this message
Andrew Hayzen (ahayzen) wrote : Re: [Bug 1358275] Re: SongsModel.status is not set as MediaStatus.Ready if rowCount is zero

The case we have is not when filtering the model to be empty, but when
mediascanner has no music in its index (eg nothing in ~/Music) it then
wasn't changing the status. Sorry we should have been more clear in the bug.

I'll be able to double check this with your example later, but you may be
able to confirm it before I get back.

On 20 August 2014 09:03, James Henstridge <email address hidden>
wrote:

> Can you provide some code that demonstrates the bug?
>
> I put together this simple program to try and reproduce the problem, but
> came up blank. When I run it, I get the following output:
>
> qml: Status changed to 1, count = 0
> qml: Status changed to 0, count = 5784
>
> So the status property's notify signal is correctly firing for the
> Loading and Ready state changes. When I press enter, which updates the
> model to filter for artist "no such artist", I get some more output:
>
> qml: Status changed to 1, count = 0
> qml: Status changed to 0, count = 0
>
> Since both the row count and status properties have notify signals, the
> bottom text component in the UI also updates to say "empty" at this
> point.
>
> ** Attachment added: "model-status-change.qml"
>
> https://bugs.launchpad.net/mediascanner2/+bug/1358275/+attachment/4182284/+files/model-status-change.qml
>
> ** Changed in: mediascanner2
> Status: New => Incomplete
>
> --
> You received this bug notification because you are subscribed to Ubuntu
> Music App.
> https://bugs.launchpad.net/bugs/1358275
>
> Title:
> SongsModel.status is not set as MediaStatus.Ready if rowCount is zero
>
> Status in Media Scanner v2:
> Incomplete
> Status in Music application for Ubuntu devices:
> New
>
> Bug description:
> Currently the Music app is attempting to integrate Content Hub support
> with the help of the streaming models provided by Mediascanner [1].
> One of the changes we making is to properly detect when the models are
> loading vs there being no music on the device. Right now we are
> catching the onFilled signal to set the model to a 'populated' state.
> However, this also means that when new media is found (either by the
> user copying songs over, or because a song is imported via content
> hub) the rowCount is reset and we briefly detect that there is no
> music.
>
> We are trying to make this check detect the empty state 1)
> allSongsModel.rowCount === 0 and 2) SongsModel.status ===
> ModelStatus.Ready. However SongsModel.status never seems to be in the
> Ready state when rowCount is zero.
>
> [1] https://code.launchpad.net/~andrew-hayzen/music-app/content-hub-
> dest-support/+merge/231037
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/mediascanner2/+bug/1358275/+subscriptions
>

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

There is no special casing of an empty index in the model update code, so a query that returns no data should trigger the same behaviour as an index with no data to return.

To test this, I stopped the mediascanner daemon and manually deleted all the rows in the index. I'm still getting the same number of statusChanged signals as before (although it no longer claims I have 5784 songs the first time), and the "empty" text in my test program behaves as expected.

I can keep on searching for problems, but I think I'll need a bit more information to track this down.

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

Aha. I think I've got it. In your merge proposal you have:

+ // FIXME: use allSongsModel.status === allSongsModel.Ready when lp:1358275 is resolved

If you were using that particular expression, then things wouldn't work because allSongsModel.Ready is not the same as SongsModel.Ready.

The constants are only accessible on the class and not instances of the class, so "allSongsModel.Ready" is the undefined value, and will never be equal to allSongsModel.status. This seems to be common for all classes exposing enumerations to QML.

Does that sound like a plausible explanation of what you're encountering?

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

Ah yes that sounds more plausible, I'll try changing the code tonight.
Thanks for looking into this :)

On 20 August 2014 10:55, James Henstridge <email address hidden>
wrote:

> Aha. I think I've got it. In your merge proposal you have:
>
> + // FIXME: use allSongsModel.status === allSongsModel.Ready when
> lp:1358275 is resolved
>
> If you were using that particular expression, then things wouldn't work
> because allSongsModel.Ready is not the same as SongsModel.Ready.
>
> The constants are only accessible on the class and not instances of the
> class, so "allSongsModel.Ready" is the undefined value, and will never
> be equal to allSongsModel.status. This seems to be common for all
> classes exposing enumerations to QML.
>
> Does that sound like a plausible explanation of what you're
> encountering?
>
> --
> You received this bug notification because you are subscribed to Ubuntu
> Music App.
> https://bugs.launchpad.net/bugs/1358275
>
> Title:
> SongsModel.status is not set as MediaStatus.Ready if rowCount is zero
>
> Status in Media Scanner v2:
> Incomplete
> Status in Music application for Ubuntu devices:
> New
>
> Bug description:
> Currently the Music app is attempting to integrate Content Hub support
> with the help of the streaming models provided by Mediascanner [1].
> One of the changes we making is to properly detect when the models are
> loading vs there being no music on the device. Right now we are
> catching the onFilled signal to set the model to a 'populated' state.
> However, this also means that when new media is found (either by the
> user copying songs over, or because a song is imported via content
> hub) the rowCount is reset and we briefly detect that there is no
> music.
>
> We are trying to make this check detect the empty state 1)
> allSongsModel.rowCount === 0 and 2) SongsModel.status ===
> ModelStatus.Ready. However SongsModel.status never seems to be in the
> Ready state when rowCount is zero.
>
> [1] https://code.launchpad.net/~andrew-hayzen/music-app/content-hub-
> dest-support/+merge/231037
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/mediascanner2/+bug/1358275/+subscriptions
>

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

Ok looks like that was the issue thanks for your help James and sorry for not picking that up ourselves. We have this mp [0] which once it lands should remove our dependence on the filled signal so then you can remove it if you wish.

0 - https://code.launchpad.net/~andrew-hayzen/music-app/fix-no-music-use-model-status/+merge/231547

Changed in music-app:
status: New → In Progress
assignee: nobody → Andrew Hayzen (andrew-hayzen)
Changed in mediascanner2:
status: Incomplete → Invalid
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

Fix committed into lp:music-app at revision 591, 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
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.