Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with exception #133

Open
rickerk6gdo opened this issue Nov 15, 2018 · 12 comments
Open

issue with exception #133

rickerk6gdo opened this issue Nov 15, 2018 · 12 comments

Comments

@rickerk6gdo
Copy link

rickerk6gdo commented Nov 15, 2018

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;

		}
	}
@rikkit
Copy link
Member

rikkit commented Nov 16, 2018

Can you post the stack trace of the exception?

@rickerk6gdo
Copy link
Author

there is none.. attached screenshot . If I take the LFM code out, no fault

lastfmerror

@rikkit
Copy link
Member

rikkit commented Nov 18, 2018

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?

@rickerk6gdo
Copy link
Author

No problem, what's a good way to send it to only you.

@rickerk6gdo
Copy link
Author

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;
	    });

@rickerk6gdo
Copy link
Author

Rikki?

@rikkit
Copy link
Member

rikkit commented Nov 27, 2018

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.

@rickerk6gdo
Copy link
Author

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.

@rickerk6gdo
Copy link
Author

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#

@rikkit
Copy link
Member

rikkit commented Dec 13, 2018

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)

@rickerk6gdo
Copy link
Author

rickerk6gdo commented Dec 13, 2018 via email

@rikkit
Copy link
Member

rikkit commented Dec 14, 2018

If you're in VS - try unticking the "Just My Code" option in the debugger when you repro. You might get a better stacktrace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants