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 559654 - tuning in to last.fm only works randomly
tuning in to last.fm only works randomly
Status: RESOLVED FIXED
Product: banshee
Classification: Other
Component: Last.fm
git master
Other Mac OS
: Normal normal
: 1.x
Assigned To: Gabriel Burt
: 559653 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-11-06 20:19 UTC by Flo
Modified: 2009-02-27 16:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Don't use Environment.CurrentDirectory to determine base uri. (865 bytes, patch)
2008-11-26 03:33 UTC, Eoin Hennessy
rejected Details | Review
Test app demonstrating the issue. (2.17 KB, text/plain)
2008-12-27 01:29 UTC, Eoin Hennessy
  Details
This is the playlist recieved from lastfm in the above test app. (2.38 KB, text/plain)
2008-12-27 01:31 UTC, Eoin Hennessy
  Details
Patch: If creating the default base uri using the cwd fails, default to Location. (803 bytes, patch)
2009-02-26 05:52 UTC, Eoin Hennessy
accepted-commit_now Details | Review

Description Flo 2008-11-06 20:19:39 UTC
Please describe the problem:
Quite often you have to close and restart banshee for last.fm to work. It will always get the data for the overview page, but quite often no actual tracks for any station.

Steps to reproduce:
1. Start banshee on os x
2. Check if the last.fm part will get tracks for a station and play them
3. if not, close and restart till it does


Actual results:
Sometime last.fm stations work, sometimes not.

Expected results:
That tuning into a station and playing stuff works more reliably.

Does this happen every time?
Not 100%, but very often.

Other information:
Comment 1 Eoin Hennessy 2008-11-24 18:30:41 UTC
The problem appears to be in 'Media.Playlists.Xspf/Playlist.cs::DefaultBaseUri'.

When running from a bundle on OSX, System.Environment.CurrentDirectory is '/', and not the assembly path. Therefore, playlist parsing fails and songs are not added to the lastfm/radio playlists.  

It seems to me that relying on CurrentDirectory to point to the assembly path is incorrect and we should be using the following instead?

   System.Reflection.Assembly.GetEntryAssembly().Location;


Comment 2 Eoin Hennessy 2008-11-24 18:35:11 UTC
*** Bug 559653 has been marked as a duplicate of this bug. ***
Comment 3 Eoin Hennessy 2008-11-26 03:33:37 UTC
Created attachment 123397 [details] [review]
Don't use Environment.CurrentDirectory to determine base uri.

This patch removes the use of Environment.CurrentDirectory to determine the base uri in Playlist.cs. I'm not sure why the base uri is required for Xspf parsing, but when running from a bundle on OSX the CurrentDirectory is '/' which leads to an InvalidUri exception during parsing. Relying instead on System.Reflection to determine the base uri fixes this issue.
Comment 4 Gabriel Burt 2008-11-27 01:17:49 UTC
Huh, I'm not sure why either of the CurrentDirectory or the GetEntryAssembly().Location are there at all.  When would their values ever be useful?  Seems like the default_base_uri should just be null.  Does that make sense?  If so, can you test it, make sure things still work?
Comment 5 Eoin Hennessy 2008-11-27 04:52:55 UTC
It looks like DefaultBaseUri is used in cases where the base document doesn't contain an 'xml:base' attribute. An instantiated Uri object must always be valid, therefore setting DefaultBaseUri to null isn't possible. So, what's required here is setting DefaultbaseUri to a valid URI. In some cases Environment.CurrentDirectory is not valid, so we need something else. I guess the assembly path is always going to be valid? Why not just hardcode it to something sensible?
Comment 6 Eoin Hennessy 2008-12-27 01:29:15 UTC
Created attachment 125371 [details]
Test app demonstrating the issue.

This app tunes a lastfm station and creates an Xspf playlist from the result. This shows how setting Xspf.Playlist.DefaultBaseUri to Environment.CurrentDirectory breaks on OSX when running from a bundle.

Compile and run as follows to simulate running from a bundle:
   pushd / && mono --debug /path/to/PlaylistTest.exe [lastfm-username] [lastfm-password] && popd
Comment 7 Eoin Hennessy 2008-12-27 01:31:44 UTC
Created attachment 125372 [details]
This is the playlist recieved from lastfm in the above test app.
Comment 8 Gabriel Burt 2009-01-14 19:18:30 UTC
http://www.xspf.org/xspf-v1.html#rfc.section.6.2 explains the rules for relative uris in xspf
Comment 9 Eoin Hennessy 2009-02-25 03:38:49 UTC
Having looked at the XSPF docs, base_uri is required but not contained in the response from last.fm. So we can either use:

  1) 'The base URI is the URI used to retrieve the entity.'

or;

  2) 'The base URI is defined by the context of the application.'

We're currently using option 2, i.e. defaulting to Environment.CurrentDirectory.. which is not guaranteed to be a valid URI.

So, in the case where option 2 fails, can we use option 1 and just set it to the original URI?
Comment 10 Eoin Hennessy 2009-02-26 05:52:05 UTC
Created attachment 129545 [details] [review]
Patch: If creating the default base uri using the cwd fails, default to Location.
Comment 11 Gabriel Burt 2009-02-26 17:25:21 UTC
Looks fine, please commit.