Bug 61069 - Contents are missing to render when we open a UIActivityViewController.
Summary: Contents are missing to render when we open a UIActivityViewController.
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 11.0 (xcode9)
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-12-11 11:35 UTC by Balasubramanian
Modified: 2017-12-14 12:42 UTC (History)
3 users (show)

Tags: UIActivityViewController, UiMailComposeViewController
Is this bug a regression?: Yes
Last known good build: iOS 10.0


Attachments
Issue reproducing sample. (24.86 KB, application/x-zip-compressed)
2017-12-11 11:35 UTC, Balasubramanian
Details
Swift sample following the C# sample implementation. (50.14 KB, application/zip)
2017-12-14 12:42 UTC, Manuel de la Peña [MSFT]
Details


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:
Status:
RESOLVED ANSWERED

Description Balasubramanian 2017-12-11 11:35:00 UTC
Created attachment 25972 [details]
Issue reproducing sample.

Hi Support,

We have drawn the Rectangle in the layer of the UIImageView. If we try to open a UIActivityViewController in a button handle, contents drawn in the layer gets cleared. We have attached with this thread for reproducing the issue in your end.

iOS version: 11 or more
Xamarin.iOS SDK: 11 or more

Issue with controllers:  UIActivityViewController, UIMailComposeViewController

Can you please look into this issue and provide the details ASAP.

Note: We cannot reproduce this issue in iOS 10 or below.

Thanks,
Balasubramanian S
Comment 1 Manuel de la Peña [MSFT] 2017-12-12 12:46:17 UTC
Hello,

I do not quite understand what is trying to be achieved in the sample code. As far as I understand, you want to draw a red rectangle in a view that will be correctly drawn and will be kept after the button has been clicked. The implementation is something I quite do not understand. 

In order to achieve what you are attempting, I would modify the ImageEx as follows:

[Register("ImageViewEx")]
public class ImageViewEx : UIView
{
	internal nint PageNumber = 0;

	public ImageViewEx(IntPtr p) : base(p)
	{               //Your initialization code.
			Initialize();
	}

	public ImageViewEx()
	{
		Initialize();
	}

	public ImageViewEx(CGRect bounds) : base(bounds)
	{
	}

	public override void Draw(CGRect rect)
	{
		using (var context = UIGraphics.GetCurrentContext())
		{
			var myRectangleButtonPath = new CGPath();
			myRectangleButtonPath.AddRect(
                            new RectangleF(new PointF(100, 10), new SizeF(200, 400)));
			context.SetFillColor((UIColor.Red).CGColor);
			context.AddPath(myRectangleButtonPath);
			context.DrawPath(CGPathDrawingMode.FillStroke);
		}
	}
}

Of course, this is a very dull example, and I'm assuming you are attempting to use a CATiledLayer to do more interesting things (maybe show a huge large image). I recommend you take a look at the implementation in the following sample => https://developer.xamarin.com/samples/monotouch/FrogScroller/

The sample interests you in the following path => https://github.com/xamarin/ios-samples/blob/master/FrogScroller/FrogScroller/TilingView.cs This path shows you a UIView subclass that uses a CATiledLayer which I think is what you are trying to attempt in the sample you provided.
Comment 2 Balasubramanian 2017-12-12 14:26:42 UTC
Hi Manuel,

Thank you for the update.

Like you said, We draw the images in the CATiledLayer. In this case, the drawn images are cleared once the share activity controller disappeared. In order to reproduce the issue, we have drawn the rectangle to the layer of the UIImageView and we could see a similar behavior (Rectangle contents are cleared when the share activity controller once disappeared from the UIViewController) in the attached sample too. We could not reproduce this issue in iOS 10 or below. Can you please look at the sample and let me know why it is happening in iOS 11 alone?

Thanks,
Bala
Comment 3 Balasubramanian 2017-12-12 14:28:36 UTC
Hi Manuel,

We cannot reproduce this issue, If we draw the rectangle straight away to the graphics of the UIView. We could reproduce the issue only if we draw the rectangle on the Layer of the UIView.

Thanks,
Bala
Comment 4 Manuel de la Peña [MSFT] 2017-12-14 12:42:25 UTC
Created attachment 26003 [details]
Swift sample following the C# sample implementation.

Hello,

I did take a look at your sample project, and as I mentioned, the implementation you are using is not quite right and the behaviour you are experience is the expected one with the code you provided. Please, take a look at the sample I pointed that shows how to correctly used a CATiledLayer for the drawing of large images. 

In order to show you that the issue is not related with Xamarin, please take a look at the sample I have written in swift that follows the design you did. As you can see, when you ran in on iOS 11 the behaviour is the same one as the one shown in your sample, if you run the sample in iOS 10 you will have the old behaviour. 

PS: You will notice that the swift sample does not use a event handler but a reference to the view, that is a small detail that had to be changed due to swift.