After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 666981 - [LibraryWatcher] Banshee crashes when importing a CD
[LibraryWatcher] Banshee crashes when importing a CD
Status: RESOLVED FIXED
Product: banshee
Classification: Other
Component: Importing
2.3.3
Other Linux
: Normal normal
: ---
Assigned To: Andrés G. Aragoneses (IRC: knocte)
Banshee Maintainers
: 667019 (view as bug list)
Depends on:
Blocks: 638939
 
 
Reported: 2011-12-29 12:38 UTC by Jorge Veiga
Modified: 2012-02-22 20:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Log file of the execution. (11.22 KB, text/plain)
2011-12-29 12:38 UTC, Jorge Veiga
  Details
stdout when fault occurs - different environment, same fault. (3.99 KB, text/plain)
2012-02-04 04:05 UTC, Jim Patterson
  Details
proposed patch (8.06 KB, patch)
2012-02-20 00:02 UTC, Andrés G. Aragoneses (IRC: knocte)
needs-work Details | Review
proposed patch, v2 (5.09 KB, patch)
2012-02-21 01:44 UTC, Andrés G. Aragoneses (IRC: knocte)
committed Details | Review

Description Jorge Veiga 2011-12-29 12:38:23 UTC
Created attachment 204313 [details]
Log file of the execution.

When I try to import a CD, Banshee crashes. Apparently the cause of this is that Banshee creates a new empty file for the first track, and then tries to import it to the collection. The file wich is being imported is empty, so it causes an exception and Banshee exits.
Comment 1 Bertrand Lorentz 2011-12-29 13:36:25 UTC
Thank you for your bug report.

The log files show that the Library Watcher extension is enabled. It sometimes causes problems when importing tracks. In your case, it maybe tries to import the track before it is actually converted from the CD.

Could you disable it and try to reproduce the problem ?
Comment 2 Jorge Veiga 2011-12-29 16:33:47 UTC
Of course, disabling the Library Watcher it works correctly.

Thank you very much.
Comment 3 Bertrand Lorentz 2011-12-30 11:17:29 UTC
*** Bug 667019 has been marked as a duplicate of this bug. ***
Comment 4 Jim Patterson 2012-02-04 04:05:47 UTC
Created attachment 206747 [details]
stdout when fault occurs - different environment, same fault.

Errors shown in English, and only for faulting thread.

Banshee 2.3.4 running on Ubuntu 11.10
Comment 5 Jim Patterson 2012-02-04 04:07:47 UTC
I've been running into same fault in recent weeks - see the attached log. It's very annoying. If a track file is empty, just ignore it!
Comment 6 Andrés G. Aragoneses (IRC: knocte) 2012-02-04 14:47:12 UTC
Apparently this bug has been exposed by a new feature in 2.3.x development series.

If you wanted more stability, you should have sticked maybe with 2.2.x stable series. If you didn't, thanks for testing.

So currently you can either disable the LibraryWatcher or stick with Banshee 2.2.x, or wait until we fix it (hopefully I'll have some time to look at it in the next weeks, but help welcome!).

Confirming due to having more than 1 person reproducing it.
Comment 7 Bertrand Lorentz 2012-02-15 19:38:04 UTC
I've just committed a fix so that we don't crash when there's an exception while the LibraryWatcher processes tracks :
http://git.gnome.org/browse/banshee/commit/?id=7f70949db

This doesn't fix the root of the problem (the interaction between importing a CD and the LibraryWatcher), so I'm leaving this bug open.
Comment 8 Andrés G. Aragoneses (IRC: knocte) 2012-02-15 23:02:45 UTC
Thanks Bertrand! I have a fix in the works (haven't tested it yet). Hopefully I'll have time to finish it before the 2.3.6 release.
Comment 9 Andrés G. Aragoneses (IRC: knocte) 2012-02-20 00:02:04 UTC
Created attachment 208009 [details] [review]
proposed patch

As described in the commit message, this patch is likely to fix bug 655752 as well.
Comment 10 Bertrand Lorentz 2012-02-20 18:02:17 UTC
Review of attachment 208009 [details] [review]:

Thanks for the patch !
I think its a good approach, but I'm wondering if 10 seconds is enough (we might be waiting for a big file to be transcoded). But with a longer delay the user could get impatient and wonder why his files are not showing up...

Maybe the SourceWatcher could figure out that some import operation is ongoing and suspend itself until it's finished ? Especially since in the case of importing a CD, the Watcher doesn't need to do anything, the files will be imported anyway. Not sure if that's a reasonable or feasible idea...

::: src/Extensions/Banshee.LibraryWatcher/Banshee.LibraryWatcher/SourceWatcher.cs
@@ +100,3 @@
             watcher = new FileSystemWatcher (path);
             watcher.IncludeSubdirectories = true;
+            watcher.Changed += OnModification;

I agree on the name change to reduce confusion, but event handlers should be named with a verb: "OnModified"
Blame the "Framework Design Guidelines" book ;)

@@ +151,3 @@
+            var timer = CreateTimer (fullpath);
+            lock (created_items_lock) {
+            timer.Elapsed += (sender, e) => TimeUpForChangedEvent (fullpath);

Is it necessary to use a specific object for the lock ?
I think it would be simpler to just use created_items_bag for that, as you've done in TimeUpForChangedEvent (probably by mistake).

@@ +163,3 @@
+            timer.Stop ();
+            timer.Start ();
+            var timer = CreateTimer (fullpath);

That return statement is not necessary.

@@ -187,3 @@
-                        change_types |= item.ChangeType;
-                    } catch (Exception e) {
-                            RemoveTrack (item.FullPath);

Is it a good idea to remove the try/catch clause ?
I added it so that a problem when importing or updating a track wouldn't crash the whole app. Better for a change to be ignored than to crash...
Comment 11 Andrés G. Aragoneses (IRC: knocte) 2012-02-21 01:44:09 UTC
Created attachment 208078 [details] [review]
proposed patch, v2

(In reply to comment #10)
> Review of attachment 208009 [details] [review]:
> 
> Thanks for the patch !

Thanks for the prompt review!

> I think its a good approach, but I'm wondering if 10 seconds is enough (we
> might be waiting for a big file to be transcoded). But with a longer delay the
> user could get impatient and wonder why his files are not showing up...

If you ask me this, I'm not sure you understood completely the approach :)

10 seconds would be the maximum to consider between the changed events. I've tested this and I get normally around 10 events per second, so I'm already being quite generous. Take in account that every time a Changed event happens, the timer gets restarted (it starts to count from 0 again) so literally reaching 10 seconds between a Changed event and the next one is almost impossible, and still a reasonable delay for the user to see a new file appearing on their library after a change happens.


> Maybe the SourceWatcher could figure out that some import operation is ongoing
> and suspend itself until it's finished ? Especially since in the case of
> importing a CD, the Watcher doesn't need to do anything, the files will be
> imported anyway. Not sure if that's a reasonable or feasible idea...

I guess we can discard this idea then?

> :::
> src/Extensions/Banshee.LibraryWatcher/Banshee.LibraryWatcher/SourceWatcher.cs
> @@ +100,3 @@
>              watcher = new FileSystemWatcher (path);
>              watcher.IncludeSubdirectories = true;
> +            watcher.Changed += OnModification;
> 
> I agree on the name change to reduce confusion, but event handlers should be
> named with a verb: "OnModified"
> Blame the "Framework Design Guidelines" book ;)

Good catch. I've actually thought about it and there's no point in mixing these changes, so I've already pushed to master this renaming. The patch I'm posting now is based on this (after this commit).

> 
> @@ +151,3 @@
> +            var timer = CreateTimer (fullpath);
> +            lock (created_items_lock) {
> +            timer.Elapsed += (sender, e) => TimeUpForChangedEvent (fullpath);
> 
> Is it necessary to use a specific object for the lock ?
> I think it would be simpler to just use created_items_bag for that, as you've
> done in TimeUpForChangedEvent (probably by mistake).

Oh, yes, I didn't mean to use it in TimeUpForChangedEvent hehe.
Well, it's always a good practice to use a different object (because it's always safe). But in the case that the collection is not public/internal it's not really necessary, so I've changed it to use the collection instead.

> @@ +163,3 @@
> +            timer.Stop ();
> +            timer.Start ();
> +            var timer = CreateTimer (fullpath);
> 
> That return statement is not necessary.

Removed.

> 
> @@ -187,3 @@
> -                        change_types |= item.ChangeType;
> -                    } catch (Exception e) {
> -                            RemoveTrack (item.FullPath);
> 
> Is it a good idea to remove the try/catch clause ?
> I added it so that a problem when importing or updating a track wouldn't crash
> the whole app. Better for a change to be ignored than to crash...

Mmm, I guess it's fine to leave it there.

You know, as our "Improva Banshee via reporting anonymous statistical usage" feature doesn't catch yet every uncaught exception (would be nice to have no?) I'm always kind of reluctant to hide unexpected stuff in logs. If we had caught this exception in the past, users would not have got a crash and would not have this bug report ;)
Comment 12 Andrés G. Aragoneses (IRC: knocte) 2012-02-21 01:47:42 UTC
s/Improva/Improve

s/not have this bug report/not have *sent* this bug report/
Comment 13 Bertrand Lorentz 2012-02-22 20:15:30 UTC
(In reply to comment #11)
> (In reply to comment #10)
> > Review of attachment 208009 [details] [review] [details]:
> > 
> > Thanks for the patch !
> 
> Thanks for the prompt review!
> 
> > I think its a good approach, but I'm wondering if 10 seconds is enough (we
> > might be waiting for a big file to be transcoded). But with a longer delay the
> > user could get impatient and wonder why his files are not showing up...
> 
> If you ask me this, I'm not sure you understood completely the approach :)
> 
> 10 seconds would be the maximum to consider between the changed events. I've
> tested this and I get normally around 10 events per second, so I'm already
> being quite generous. Take in account that every time a Changed event happens,
> the timer gets restarted (it starts to count from 0 again) so literally
> reaching 10 seconds between a Changed event and the next one is almost
> impossible, and still a reasonable delay for the user to see a new file
> appearing on their library after a change happens.

For some unknown reason I assumed we'd only get an event for the creation, and then a "changed" event when the file was completely transcoded. This is wrong, so forget my remark.
Comment 14 Bertrand Lorentz 2012-02-22 20:15:52 UTC
Comment on attachment 208078 [details] [review]
proposed patch, v2

I've committed this, with a few minor changes:
http://git.gnome.org/browse/banshee/commit/?id=cf2346be3
Comment 15 Bertrand Lorentz 2012-02-22 20:16:23 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.