Music with invalid year field (-1) in metadata causes mediascanner to crash

Bug #1436110 reported by SB
24
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Canonical System Image
Fix Released
Undecided
Unassigned
Ubuntu Music App
Invalid
Undecided
Unassigned
mediascanner2
Fix Released
High
James Henstridge
mediascanner2 (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Music which has the value -1 in the year field causes mediascanner2 to crash. This then causes problems to the clients, eg Music-app, as they cannot read the tracks in the store or add tracks via a content-hub import.

-- Original bug report--
When I use the file manager application to open a mp3 file from SD card Music says "waiting for file" and then "imported file not found" even though it plays that file normally when opened directly from Music.

BQ Aquaris HD4.5 Ubuntu Edition fully updated and running on 14.10 r20.

Related branches

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

Thank you for taking the time to report this bug and helping to make Ubuntu better.

Personally I believe the file manager should be using url-handler instead of content-hub in this case as the music already exists in the target location (on SD card/Music or in ~/Music) and does not need to be imported.

However mediascanner should have scanned the audio files on your SD card already. So if you open the music-app by itself the tracks should be there already and you shouldn't have to use file manager to play them, can you confirm if this is true?

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

Oh sorry I missed "even though it plays that file normally when opened directly from Music".

So this is more interesting that the file failed to import, are you able to provide a copy of the logs?

From the location /home/phablet/.cache/upstart can you attach mediascanner2.log and there should be one that mentions com.ubuntu.music.

Revision history for this message
SB (emehntehtt) wrote :

I retried the same operation and then checked the log but com.ubuntu.music is not found anywhere within the log, but numerous errors are seen:

Mediascanner service starting at 2015-03-25 2:33:09.

Volume /media/phablet/B862-C33E was mounted.
0 files deleted from disk or in scanblocked directories.
In subdir /media/phablet/B862-C33E
In subdir /media/phablet/B862-C33E/Videos
In subdir /media/phablet/B862-C33E/Videos/com.ubuntu.camera
In subdir /media/phablet/B862-C33E/Pictures
In subdir /media/phablet/B862-C33E/Pictures/Slike
In subdir /media/phablet/B862-C33E/Pictures/com.ubuntu.camera
In subdir /media/phablet/B862-C33E/Music
In subdir /media/phablet/B862-C33E/Music/Zanov - Moebius
In subdir /media/phablet/B862-C33E/Music/Zanov - In Course of Time
Extracting metadata from /media/phablet/B862-C33E/Music/Zanov - In Course of Time/4. In Course of Time.mp3.

(mediascanner-service-2.0:2730): GStreamer-CRITICAL **: gst_date_time_new: assertion 'year > 0 && year <= 9999' failed

(mediascanner-service-2.0:2730): GStreamer-CRITICAL **: gst_mini_object_unref: assertion 'mini_object != NULL' failed

(mediascanner-service-2.0:2730): GStreamer-CRITICAL **: gst_date_time_to_iso8601_string: assertion 'datetime != NULL' failed
terminate called after throwing an instance of 'std::logic_error'
  what(): basic_string::_S_construct null not valid

Mediascanner service starting at 2015-03-25 2:33:12.

Volume /media/phablet/B862-C33E was mounted.

The thing is, the track that seems to throw these errors (or so it seems) is not the track I attempted to open via File Manager. The mediascanner log is filled with this error concerning 4. In Course of Time.mp3 track, maybe its corrupted or something, but there is no mention of com.ubuntu.music, attaching the whole log if that helps.

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

Thanks :) It would be useful if you could provide the music app log as well, usually I run this command to find the filename

$ ls -ltr /home/phablet/.cache/upstart | grep music

Then take the bottom entry (should be along the lines of application-click-com.ubuntu.music_music_2.0.845.log)

Revision history for this message
SB (emehntehtt) wrote :

OK I attached the requested log.

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

Thanks :)

I spot lots of "Error finalising statement: Could not finalize statement: database is locked" this is likely due to mediascanner still attempting to scan your SD while you are running the import (or mediascanner has crashed and has locked the db somehow).

Therefore could you try again importing the file via the file manager, as the import scan has likely finished.

If that fails could you try restarting the device in case mediascanner has crashed and then wait a period after rebooting to ensure the scan has finished.

If this still fails it could be possible the "what(): basic_string::_S_construct null not valid" when scanning your media is causing mediascanner to crash and leave the database locked.

Revision history for this message
SB (emehntehtt) wrote :

I will try those steps but I think I tried rebooting already, will do it again and wait for a while and try again. If the case is that "what(): basic_string::_S_construct null not valid" is locking my database do you know what can cause such a problem, and what can I do to prevent that :)

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

Looking again at the mediascanner logs every time the following errors/warnings appear the service restarts itself directly after, this is probably what is causing the database to be left locked. Therefore I am adding mediascanner2 as also affects to this bug.

(mediascanner-service-2.0:4547): GStreamer-CRITICAL **: gst_date_time_new: assertion 'year > 0 && year <= 9999' failed

(mediascanner-service-2.0:4547): GStreamer-CRITICAL **: gst_mini_object_unref: assertion 'mini_object != NULL' failed

(mediascanner-service-2.0:4547): GStreamer-CRITICAL **: gst_date_time_to_iso8601_string: assertion 'datetime != NULL' failed
terminate called after throwing an instance of 'std::logic_error'
  what(): basic_string::_S_construct null not valid

Mediascanner service starting at 2015-03-25 12:43:07.

To answer, "What can I do to prevent that?", it looks like alot of your audio files have none/invalid metadata for the year field so you could manually set these and then try importing again. However for testing purposes for this bug it would be useful to keep a copy of the original files that were causing the error (maybe you could pm one of them to me?) so we know that is the issue has been fixed.

Revision history for this message
SB (emehntehtt) wrote :

I emailed you the track that seems to be causing a lot of errors, hope that helps.

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

So, the problem code in MetadataExtractor.cc:

        } else if (G_VALUE_HOLDS(val, GST_TYPE_DATE_TIME)) {
            if (tagname == GST_TAG_DATE_TIME) {
                GstDateTime *dt = static_cast<GstDateTime*>(g_value_get_boxed(val));
                char *dt_string = gst_date_time_to_iso8601_string(dt);
                mfb->setDate(dt_string);
                g_free(dt_string);
            }

Where we aren't checking that the value stored in the GValue is NULL. I'd be interested to know what the date is set to in the problem file's metadata (e.g. as printed by the id3v2 utility).

Changed in mediascanner2:
status: New → Confirmed
Revision history for this message
Andrew Hayzen (ahayzen) wrote :

@James I've just forwarded you a mail with a link to a file that Edward messaged me :) Please let us know if you need any further info.

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

Looking at the file forwarded on by Andrew, the metadata is:

    id3v1 tag info for 4. In Course of Time.mp3:
    Title : In Course of Time Artist: Zanov
    Album : In Course Of Time Year: -1 , Genre: Ambient (26)
    Comment: 0 Track: 0
    4. In Course of Time.mp3: No ID3v2 tag

And -1 is certainly out of the range of what GStreamer's date type is expecting. Media scanner should be fixed to treat this as a missing date.

In the short term, you can correct this by updating the tags on your music: either remove the year tag or set it to a valid year in the range 0...9999

Changed in music-app:
status: New → Invalid
Revision history for this message
SB (emehntehtt) wrote :

Yes it is -1 in ID3v2, like you said mediascanner should treat such dates as missing or ignore them as there will be more people with incorrect tags in some of their music. Still dont know why Music does not want to play files opened via File Manager, I tried again with multiple files and it is always "waiting for file" and then reports "file not found", maybe not a bug but a feature request but it should be able to play music opened via File Manager, makes no sense that it doesnt support that.

summary: - Music refuses to play file opened via file manager
+ Music with invalid year field (-1) in metadata causes mediascanner to
+ crash
Revision history for this message
Thomas Muguet (tmuguet) wrote :

Same problem (and same cause) happened to me when dropping a bunch of tracks on my SD Card.
To me, this is a big issue because mediascanner goes into an infinite loop, draining the battery silently, and preventing other files to be scanned. And because no errors are reported directly to the user, users can't know there is something wrong without checking the CPU usage and the mediascanner logs.

Andrew Hayzen (ahayzen)
description: updated
Revision history for this message
Miguel (migueltejel-i) wrote :

Same problem here

Thomas Strehl (strehl-t)
Changed in mediascanner2:
assignee: nobody → James Henstridge (jamesh)
Thomas Strehl (strehl-t)
Changed in mediascanner2:
importance: Undecided → Medium
importance: Medium → High
Changed in mediascanner2:
status: Confirmed → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package mediascanner2 - 0.105+15.10.20150604-0ubuntu1

---------------
mediascanner2 (0.105+15.10.20150604-0ubuntu1) wily; urgency=medium

  [ James Henstridge ]
  * Treat invalid dates in MP3s as missing metadata. (LP: #1436110)

 -- CI Train Bot <email address hidden> Thu, 04 Jun 2015 06:51:43 +0000

Changed in mediascanner2 (Ubuntu):
status: New → Fix Released
Changed in mediascanner2:
status: In Progress → Fix Released
Changed in canonical-devices-system-image:
status: New → Fix Released
Revision history for this message
Torstein Finnbakk (torstein-finnbakk) wrote :

This bug is still present in my newly bought Aquaris E5, though it is newly updated. The Music app doesn't play mp3 files at all.
And there is no app for playing mp4 videos.

Revision history for this message
Pat McGowan (pat-mcgowan) wrote :

@Torstein could you please open a new bug with the specifics of your issues.
The music-app certainly plays m3s and mp4 Videos can be played directly from the Video scope.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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