Bug 23619 - MPMediaItem.ImageWithSize returns null on iOS 8
Summary: MPMediaItem.ImageWithSize returns null on iOS 8
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: XI 8.2.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-10-05 01:45 UTC by Cody Beyer (MSFT)
Modified: 2014-10-14 14:17 UTC (History)
6 users (show)

Is this bug a regression?: ---
Last known good build:

Test case (5.05 KB, application/zip)
2014-10-13 05:32 UTC, Adam Kapos

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Cody Beyer (MSFT) 2014-10-05 01:45:23 UTC
Calling ImageWithSize on an MPMediaItemArtwork that has exists (checked with Bounds.Width != 0) returns null if called with a size of 100x100. It works fine if called with a size of 120x120:
ImageWithSize(new SizeF(120, 120)).
Comment 1 Adam Kapos 2014-10-05 07:46:39 UTC
This bug occured with devices running iOS 8.0 and iOS 8.0.2.
I tested it with iOS 7.1.2 and returning a 100x100 artwork worked tine.
Comment 2 Sebastien Pouliot 2014-10-05 14:01:42 UTC
This sounds like an iOS bug (or change*) as there is no version-specific checks in our binding code (so the same code executes in both cases).

Many of us are at our Evolve conference this week but we'll try to verify this asap.

* there has been quite a few incompatible changes in iOS8.
Comment 3 Sebastien Pouliot 2014-10-05 16:51:43 UTC
A quick test shows me that the image being return is the original (not null) on iOS8 (simulator and iPad mini) and iOS 7.1 (iPhone5S).

			string file = Path.Combine (NSBundle.MainBundle.ResourcePath, "basn3p08.png");
			using (var img = UIImage.FromFile (file))
			using (var mia = new MPMediaItemArtwork (img)) {
				Assert.That (img.Size.ToString (), Is.EqualTo ("{Width=32, Height=32}"), "original");
				var wrongSize = mia.ImageWithSize (new SizeF (100, 100));
				Assert.NotNull (wrongSize);
				Assert.That (wrongSize.Size.ToString (), Is.EqualTo ("{Width=32, Height=32}"), "withSize");

Could you give us a test case where you get `null` ?
Comment 4 Adam Kapos 2014-10-05 17:44:58 UTC
In our case we are loading music from the user's media library. The album art is usually around 500x500 pixels and we are downsizing this to 100x100.

Here's the code:
(It was written by me)
Comment 5 Paola Villarreal 2014-10-10 10:08:38 UTC
On the code you posted there is not a call to ImageWithSize, perhaps it is in some of the other classes that we don't have?

A self-contained case would be perfect.
Comment 6 Adam Kapos 2014-10-11 08:31:16 UTC
There you go:

The test case is in AppDelegate's FinishedLaunching.
Comment 7 Paola Villarreal 2014-10-12 16:46:19 UTC
Your testcase still does not contain all the classes that it makes reference to (MediaLibrary, Albums, etc. Tried adding to the project the MonoGame directory contained in the .rar but it won't compile.

Still, the code inside AppDelegate is 100% your app's specific code. Could you please provide a more compact/concrete example for us to discern wether this is a Xamarin.iOS specific bug or what it is?

Thank you.
Comment 8 Adam Kapos 2014-10-13 05:32:10 UTC
Created attachment 8389 [details]
Test case

For some reason the MonoGame project reference was missing.
Anyway, here's the essence of the test case.
Comment 9 Cody Beyer (MSFT) 2014-10-14 11:54:16 UTC
New test case attached
Comment 10 Paola Villarreal 2014-10-14 12:32:38 UTC
Confirming bug.

Other tests needed to assign it. Will keep you updated.
Comment 11 Paola Villarreal 2014-10-14 14:10:53 UTC
Ok, so this bug also happens on Objective-C on iOS 8, according to this Stack Overflow post: 


May I suggest you file a bug with Apple about this?