Bug 44686 - XAMARIN Project fails to load image asset on iOS10 but is working on iOS9.3
Summary: XAMARIN Project fails to load image asset on iOS10 but is working on iOS9.3
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 10.0 (iOS10)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Future Cycle (TBD)
Assignee: Bugzilla
Depends on:
Reported: 2016-09-23 16:32 UTC by Matthew
Modified: 2016-12-08 01:37 UTC (History)
6 users (show)

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

iOS10 (89.61 KB, image/png)
2016-09-23 16:32 UTC, Matthew

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 Matthew 2016-09-23 16:32:28 UTC
Created attachment 17713 [details]

Unsure if I should log a report to Apple or Xamarin but I'll start the discussion here/


Comment 1 Alex Soto [MSFT] 2016-09-26 08:11:11 UTC
Hello Thanks for contacting us!

Please include a test case so we can reproduce your issue, your full build logs (add -v -v -v -v in additional mtouch arguments inside the project dialog), crash reports (if any) and all version informations.

The easiest way to get exact version information is to use the 
"Xamarin Studio" menu, "About Xamarin Studio" item, "Show Details" 
button and copy/paste the version informations (you can use the 
"Copy Information" button).
Comment 2 Matthew 2016-09-27 10:30:53 UTC
Here are 3 videos, with logs for each.

1. This demonstrates that the live app works fine on iOS 9.3 devices.

2. This demonstrates that the background fails to load on an iOS10 Device. Also you get a white background on the Login Screen.

Here is a build log for (2.)

Here is the Application Output for (2.). When the app opens, I goto the signup screen and login screen.

3. These demonstrate how it appears in the simulator. The background loads fine, but you get the white background on the Login Screen until you tap it.

This is a system log when the user tries to go on the Login Screen when the white background appears. This is for (3.)

I'm posting below the version details. I just updated my xamarin this morning, but the behaviour is all identical.
Xamarin Studio Community
Version 6.1.1 (build 15)
Installation UUID: 988898cc-0646-484c-b6eb-7ed8a01f1d65
	Mono 4.6.1 (mono-4.6.0-branch-c8sr0/abb06f1) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 406010003


Not Installed

Apple Developer Tools
Xcode 8.0 (11246)
Build 8A218a

Version: (Xamarin Studio Community)

Version: (Xamarin Studio Community)
Hash: 3983064
Branch: cycle8-sr0-xi
Build date: 2016-09-23 15:34:54-0400

Version: (Xamarin Studio Community)
Android SDK: /Users/matthewmanuel/Library/Android/sdk
	Supported Android versions:
		4.1 (API level 16)
		5.0 (API level 21)
		5.1 (API level 22)
		6.0 (API level 23)
		7.0 (API level 24)

SDK Tools Version: 25.2.2
SDK Platform Tools Version: 24.0.3
SDK Build Tools Version: 24.0.2

Java SDK: /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

Android Designer EPL code available here:

Xamarin Android Player
Not Installed

Build Information
Release ID: 601010015
Git revision: fa52f02641726146e2589ed86ec4097fbe101888
Build date: 2016-09-22 08:03:02-04
Xamarin addins: 75d65712af93d54dc39ae4c42b21dfa574859fd6
Build lane: monodevelop-lion-cycle8-sr0

Operating System
Mac OS X 10.12.0
Darwin Matthews-MacBook-Pro.local 16.0.0 Darwin Kernel Version 16.0.0
    Mon Aug 29 17:56:20 PDT 2016
    root:xnu-3789.1.32~3/RELEASE_X86_64 x86_64

Enabled user installed addins
Android Signature Tool 1.0.1
MvvmCross Template pack 1.1.7
FileNesting 0.1
Macaque Tips 0.1.1
NuGet Package Management Extensions 0.11.1
Show in Github 1.0.3
Comment 3 Matthew 2016-09-27 10:48:34 UTC
I've fixed the white background on Login screen (Default color was set to white). The background failing to load persists.
Comment 4 Matthew 2016-09-27 12:44:01 UTC
Hi Guys,

After investigation in code. It turns out the background graphic is rendered programatically.

It might be an error related to CoreGraphics. 

The following piece of code is no longer working on iOS10.
private static void DrawGradientInPath(CGContext ctx, CGPath path, CGColor lowerLeftColor, CGColor upperRightColor)


            var gradient = new CGGradient(CGColorSpace.CreateDeviceRGB(),
                      new CGColor[] { lowerLeftColor, upperRightColor });
            // This fails in the simulator.
            var gradientRect = ctx.GetPathBoundingBox().Standardize();
                new CGPoint(gradientRect.Left, gradientRect.Bottom),
                new CGPoint(gradientRect.Right, gradientRect.Top),

This however works on iOS10 and in Simulator.

protected static void FillPathWithColor(CGContext ctx, CGPath path, CGColor color)


The following code is where I decide to use between which call to render the background .

private static UIColor SlantedPatternColorWithTexture(string textureCatalogName)
            UIImage textureImage = UIImage.FromBundle(textureCatalogName);

            var bounds = UIScreen.MainScreen.Bounds;
            var left_delta_y = bounds.Height * 265.0f / 667.0f;
            var right_delta_y = bounds.Height * 180.0f / 667.0f;

            var paths = CalculateUpperAndLowerPaths(left_delta_y, right_delta_y, bounds);

            UIGraphics.BeginImageContextWithOptions(UIScreen.MainScreen.Bounds.Size, false, 0.0f);

            var ctx = UIGraphics.GetCurrentContext();
            if (ObjCRuntime.Runtime.Arch == Arch.SIMULATOR)
                FillPathWithColor(ctx, paths.Upper, s_slantedUpperGradientLeftColor.CGColor);
                FillPathWithColor(ctx, paths.Lower, s_slantedLowerGradientLeftColor.CGColor);
                DrawGradientInPath(ctx, paths.Upper, s_slantedUpperGradientLeftColor.CGColor, s_slantedUpperGradientRightColor.CGColor);
                DrawGradientInPath(ctx, paths.Lower, s_slantedLowerGradientLeftColor.CGColor, s_slantedLowerGradientRightColor.CGColor);

            if (textureImage != null)
                textureImage.Draw(new CGPoint(0.0f, 0.0f));

            var combinedImage = UIGraphics.GetImageFromCurrentImageContext();


            return UIColor.FromPatternImage(combinedImage);
Comment 5 Matthew 2016-09-30 10:30:42 UTC
Hi Guys.
Just wondering if you have an update on this.
Comment 6 Marek Safar 2016-09-30 10:41:53 UTC
Comment 7 Vincent Dondain [MSFT] 2016-09-30 11:48:55 UTC
Hi Matthew,

Thanks for providing us all that information however it's a little hard to parse and there isn't much for us to act on (no error, no crash), nothing that rings a bell.

There could be many causes in your project for such an issue. I don't know if you're using external packages that are not up do date, obsolete APIs or if other elements changed in your attempt to support iOS 10.

In this case it seems to be a code issue and without obvious information in this bug, at this point, a test case (small sample app so any Xamarin.iOS team member can easily reproduce the issue) or the original full app would be the easiest way for us to understand the totality of the code, debug it and figure out what's wrong.

Though, I have to warn you that bugzilla is for bugs in our platforms, if you have problems using the API, please ask in the forums or stack overflow. It's likely you'll have more luck there finding people with experience in CoreGraphic.

I will leave this bug open as NEEDINFO until we get a test case.
Comment 8 Timothy Risi 2016-12-08 01:37:27 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and re-open the bug report. Thanks!