Bug 41684

Summary: [Regression] CGRect.Inflate does nothing as of C7
Product: iOS Reporter: Brad Moore <brad>
Component: Xamarin.iOS.dllAssignee: Rolf Bjarne Kvinge [MSFT] <rolf>
Status: VERIFIED FIXED    
Severity: normal CC: abhishekk, alex.soto, arpitj, brendan.zagaeski, dj_technohead, luis.aguilera, mono-bugs+monotouch, rbuckland, rolf, xamarinbugzilla
Priority: ---    
Version: XI 9.8 (tvOS / C7)   
Target Milestone: C7SR1   
Hardware: Macintosh   
OS: Mac OS   
Tags: BZRC7S1_C6SR4S1, DefectEscapeReview_Done Is this bug a regression?: Yes
Last known good build: Cycle 6 – Service Release 4
Attachments: Test case

Description Brad Moore 2016-06-10 09:40:48 UTC
CGRect newRect = CGRect.Inflate(new CGRect(0, 0, 50, 50), 100, 100);

newRect is identical to the rect given in the arguments.

Similarly,

CGRect newRect2 = new CGRect(0, 0, 50, 50);
newRect2.Inflate(100, 100);

newRect2 is still the same as it was initially defined. 

Our app has other issues with touches not working which we now believe to be the same thing, our inflate calls are doing nothing.
Comment 1 dj_technohead 2016-06-10 18:20:14 UTC
I am seeing the exact same issue. Using a previous version of Xamarin, and the Inflate is working.
Comment 2 Randy 2016-06-16 18:52:25 UTC
I just upgraded everything and I see the same problem in both the simulator and on the devices. Both the debug and release build work this way.

Xamarin.IOS 9.8.0.323
Comment 3 Randy 2016-06-16 19:03:22 UTC
The problem seems more basic than this. Perhaps something to do with how parameters are referenced. I tried adding this extension to work around the problem.

		public static void Inflate2 (this CGRect input, nfloat x, nfloat y)
		{
			input.X -= x;
			input.Width += x * 2;
			input.Y -= y;
			input.Height += y * 2;
		}

I can step through and see the values being changed but when I step out, the rectangle that was passed as 'input' hasn't changed. This would normally have been passed as a reference to an object so changing member values in the function would apply after this function returned. Could the handling of the CGRect have changed so it is passing it by value?
Comment 4 Randy 2016-06-16 19:09:35 UTC
The extension method I tried is failing because CGRect is a struct and is passed by value. I don't know if CGRect was a struct in the previous version.
Comment 5 Randy 2016-06-16 19:28:53 UTC
The CGRect.Inflate method isn't working either. Using:

  r = CGRect.Inflate (r, 10, 10)

Doesn't change the value of r
Comment 6 Brendan Zagaeski (Xamarin Team, assistant) 2016-06-16 22:14:12 UTC
Created attachment 16370 [details]
Test case

Just to be thorough, here's a complete test case and example results.




## Steps to replicate

Run the attached test case on simulator or device.




## BAD Results with Xamarin.iOS 9.8.0.323 (39ebb77)

The console output and the text displayed on the first screen of the app show the _same_ values for `oldRect` and `newRect`:

> {X=0,Y=0,Width=50,Height=50}
> {X=0,Y=0,Width=50,Height=50}



## GOOD Results with Xamarin.iOS 9.6.2.4 (d8bedd0)

The console output and the text displayed on the first screen of the app show different values for `oldRect` and `newRect`:

> {X=0,Y=0,Width=50,Height=50}
> {X=-100,Y=-100,Width=250,Height=250}



For good measure, I also tested with:

BAD: Xamarin.iOS 9.8.0.327 (384b09a) (in-progress development build)
Comment 7 Brendan Zagaeski (Xamarin Team, assistant) 2016-06-16 22:50:46 UTC
It looks like the problem in Xamarin.iOS is a couple missing `this` keywords:

https://github.com/xamarin/xamarin-macios/blob/5830166c63da5f71dadc9bf7ad568b288cddbfa6/src/NativeTypes/Drawing.tt#L474-L475

(The pass-by-value vs. pass-by-reference issue wouldn't be a concern for the instance method.)
Comment 8 Brad Moore 2016-06-16 23:09:46 UTC
Looking at some of the other source there is some weird inconsistencies there as well.

Like how in the Offset method it access the property X rather than this.x, unsure if that is fixed in compile time to be the same or not.

https://github.com/xamarin/xamarin-macios/blob/5830166c63da5f71dadc9bf7ad568b288cddbfa6/src/NativeTypes/Drawing.tt#L497

But either way is good to see the issue has been identified.
Comment 9 xamarinbugzilla 2016-06-17 17:13:23 UTC
How is this just "Normal" priority. Lots of my frame animation and layout math i'm doing is now COMPLETELY hosed. Honestly.
Comment 10 Brendan Zagaeski (Xamarin Team, assistant) 2016-06-17 17:40:44 UTC
To be precise, this bug is _not_ "Normal" priority.  It is "---" priority (no priority assigned at this moment).  It was submitted as "Normal" _severity_ by the original reporting user.  The Xamarin engineering team has not assigned a priority at this moment.  Keep in mind that the "priority" field is primarily used by the Xamarin team to distinguish among bugs on a particular milestone.  I have been chatting with the engineering team about how best to schedule this bug for inclusion in an upcoming release in as timely a fashion as possible.  Regressions reported by several users become a high priority regardless of the value of the priority field.


Best,
Brendan
Xamarin Customer Support
Comment 13 xamarinbugzilla 2016-06-17 18:51:39 UTC
Brendan - Just venting a bit - glad it's fixed. Any idea when that version will roll out to alpha/beta channel?
Comment 14 Brendan Zagaeski (Xamarin Team, assistant) 2016-06-20 21:10:32 UTC
## Status update for any users CC'd on the bug

The candidate fix for this issue will not yet be included as of the "Cycle 6 – Service Release 0" that is being published to the Beta updater channel today and tentatively to the Stable updater channel tomorrow.

The candidate fix for this issue _is_ planned for inclusion in the upcoming "Cycle 7 – Service Release 1" release.  The tentative publication date for that next service release is next week (the week of June 27).  I will monitor the progress of that release to check on the possibility of an initial Beta release as soon as possible.
Comment 15 Arpit Jha 2016-06-22 11:04:13 UTC
***************************************************************************************
Reproduce Status : Reproduced
***************************************************************************************

I have checked this issue with XI 9.8.0.323 and observing the same mentioned in bug description.
Screencast : http://www.screencast.com/t/VeILAios
Environment Info:  https://gist.github.com/Arpit360/9b5c98b7579f74f9db00c2f2721fb1f8

***************************************************************************************
Verify  Status : Verified
***************************************************************************************

I have checked this issue with attached XI 9.9.2.29  and its working fine.
Screencast: http://www.screencast.com/t/tl3IATtZdhz
Environment Info: https://gist.github.com/anonymous/fa9271a4bb50923c63b7aafd58e6c4ce

As per target milestone, I will verify once fixed merge to the C7SR!
Comment 16 Abhishek 2016-07-05 18:35:25 UTC
I have checked this issue with latest C7 build:
xamarin.ios-9.8.2.11_9ae33ac96b6b40c4f9f2d1638cd6640695224130
XamarinStudio-6.0.2.41_c92f57f326843c4c6e475a26d627b240ab8580f9

Now this issue is working fine. Here is the screencast for the same: http://www.screencast.com/t/FaqTecaYr

Application Output: https://gist.github.com/Abhishekk360/8c67653199191bf1c3956353465a3ca7

Hence closing this issue.

Thanks!