lastfm
lastfm copied to clipboard
issue with exception
The follow code intermittently will cause me to get the NullReferenceException Object reference not set to an instance of an object. with Xamarin forms. Even when I do the NULL check on the instance, it gives me the fault.
Ideas?
public async void GetXml( string artist, string song) { //Check network status
{
lastfmclass = new lastfmimage();
inxml = true;
var auth = new LastAuth("71b08e0", "b93eb5a3f84fc175e");
var albumApi = new AlbumApi(auth); // this is an unauthenticated call to the API
var trackApi = new TrackApi(auth); // this is an unauthenticated call to the API
var artistApi = new ArtistApi(auth); // this is an unauthenticated call to the API
var response = await trackApi.GetInfoAsync(song,artist);
var response2 = await artistApi.GetInfoAsync(artist);
var songinfo = response.Content; // visions is a LastAlbum
var artistinfo = response2.Content;
if (songinfo != null)
{
if (songinfo.AlbumName != null)
{
response1 = await albumApi.GetInfoAsync(artist, songinfo.AlbumName);
var albuminfo = response1.Content;
if (albuminfo != null)
{
lastfmclass.AlbumImage = albuminfo.Images.Large.AbsoluteUri;
}
}
}
lastfmclass.ImageUri = "";
// Debug.Assert(artistinfo.MainImage.Large.AbsoluteUri == null, "art is null");
// if (artistinfo.MainImage.Large.AbsoluteUri == null)
// {
// return;
// }
// else
if (artistinfo != null)
{
lastfmclass.ImageUri = artistinfo.MainImage.Large.AbsoluteUri;
}
//ImageUri = new UriImageSource { Uri = new Uri(prodPic) },
//public string ArtistImage => $"prefix-{OtherProperty}-suffix.png";
BindingContext = lastfmclass;
inxml = false;
}
}
Can you post the stack trace of the exception?
there is none.. attached screenshot . If I take the LFM code out, no fault
This looks like it could be related to #76.
What version of the package are you using, and can you provide some more details on the project? Is it possible to share the source in order to try to reproduce the issue?
No problem, what's a good way to send it to only you.
version of last fm is 1.1.0.339.
This will only happen intermittently . I do have it on a timer to call lastfm code
Device.StartTimer(TimeSpan.FromSeconds(10), () => { Browser.Source = (Browser.Source as UrlWebViewSource).Url; if (!inxml) lastfm();
// Set the grid to invisible
// IsGridVisible = false;
// TRUE for we want the timer to start again after this code
// If return FALSE: timer stops
return true;
});
Rikki?
Sorry @rickerk6gdo, you can email your source to hello [at] rikk [dot] it but I can't promise I'll be able to try anything soon. In the spirit of open source, could you post on this thread more details about your project? What platform? What version of .Net? What NuGet packages are you using? I don't currently have much time to investigate this for you so if this kind of info is public maybe someone else will be able to help you.
Thanks
VS 2017 with xarmain forms 3.4.10008975 Xam.plugin.media 4.0.1.5 Plugin.mediamanager 0.4.5 Inflateable..lastfm 1.1.0.339 HTML agilitypack 1.8.10
Building for IOS and android.
I guess I dont understand why I'd be getting nulls back from XML, rather than empty string sets.
finally got a call stack.
does this give any clues?
0x5C in UIKit.UIApplication.UIApplicationMain C#
0xB in UIKit.UIApplication.Main at /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.10/src/Xamarin.iOS/UIKit/UIApplication.cs:79,4 C#
0x2F in UIKit.UIApplication.Main at /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.10/src/Xamarin.iOS/UIKit/UIApplication.cs:63,4 C#
0x9 in kqlh.iOS.Application.Main at d:\stream2\kqlh\kqlh.iOS\Main.cs:19,5 C#
I don't think so. Couple of Qs
- Is it just the iOS project you experience this on? Or Android also?
- Are you calling
Inflatable.Lastfm
methods from the UI thread or a background thread? Because it looks like the UI thread is crashing from the stacktrace there. (Not 100% sure if this is a relevant question - my knowledge of threading in apps come from a Windows background, not Android or iOS)
Is it just the iOS project you experience this on? Or Android also?
both;
Are you calling Inflatable.Lastfm methods from the UI thread or a background thread? Because it looks like the UI thread is crashing from the stacktrace there. (Not 100% sure if this is a relevant question - my knowledge of threading in apps come from a Windows background, not Android or iOS) Calling them from the Mainpage.cs. This is Similar to WinMain under Windows. I set up a global var in the init code... then do a 'new' it each time I enter the function.
------ Original Message ------ From: "Rikki Tooley" [email protected] To: "inflatablefriends/lastfm" [email protected] Cc: "Rick Ruhl" [email protected]; "Mention" [email protected] Sent: 12/13/2018 7:36:46 AM Subject: Re: [inflatablefriends/lastfm] issue with exception (#133)
I don't think so. Couple of Qs
Is it just the iOS project you experience this on? Or Android also?Are you calling Inflatable.Lastfm methods from the UI thread or a background thread? Because it looks like the UI thread is crashing from the stacktrace there. (Not 100% sure if this is a relevant question - my knowledge of threading in apps come from a Windows background, not Android or iOS) — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/inflatablefriends/lastfm/issues/133#issuecomment-447012214, or mute the thread https://github.com/notifications/unsubscribe-auth/AhbR0RLAkmHvGLfzlYDXaqb9pUw33DScks5u4nQOgaJpZM4YhYPC.
If you're in VS - try unticking the "Just My Code" option in the debugger when you repro. You might get a better stacktrace.