Bug 23102 - AdaptivePhotos sample throws exception when Profile button is clicked
Summary: AdaptivePhotos sample throws exception when Profile button is clicked
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Samples ()
Version: XI 8.2.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: GouriKumari
URL:
Depends on:
Blocks:
 
Reported: 2014-09-17 11:34 UTC by John Pilczak
Modified: 2014-12-30 08:17 UTC (History)
5 users (show)

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

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:
VERIFIED FIXED

Description John Pilczak 2014-09-17 11:34:48 UTC
When running the AdaptivePhotos sample on either device or simulator, a System.ArgumentException is thrown pointing to line 146 of ProfileViewController when the Profile button is clicked.

Steps to reproduce:
1. Open the AdaptivePhotos sample
2. Click the Profile button

Expected result:
The app should display the profile

Actual result:
An exception is thrown

Application Output: https://gist.github.com/JohnPilczak/688d8c8420f4ed7ef964

Environment Info:
=== Xamarin Studio ===

Version 5.4 (build 236)
Installation UUID: ea2dde6b-0915-4e87-bf59-0163cddeada5
Runtime:
	Mono 3.8.0 ((no/45d0ba1)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 308000009

=== Apple Developer Tools ===

Xcode 6.0 (6299)
Build 6A313

=== Xamarin.iOS ===

Version: 8.0.0.60 (Business Edition)
Hash: b26679f
Branch: 
Build date: 2014-09-16 12:47:14-0400

=== Xamarin.Android ===

Version: 4.17.0 (Business Edition)
Android SDK: /Users/johnpilczak/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		1.6    (API level 4)
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.0    (API level 11)
		3.1    (API level 12)
		3.2    (API level 13)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		4.5    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin.Mac ===

Version: 1.11.0.1 (Starter Edition)

=== Build Information ===

Release ID: 504000236
Git revision: 7919b7498c2fbd22aa2f8beb7f5df597eceb742b
Build date: 2014-09-15 12:51:03-04
Xamarin addins: 209babcde541bd7445544f0a7bbd1b926e918297

=== Operating System ===

Mac OS X 10.9.4
Darwin Vinces-xMac.local 13.3.0 Darwin Kernel Version 13.3.0
    Tue Jun  3 21:27:35 PDT 2014
    root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
Comment 1 Sebastien Pouliot 2014-09-17 13:28:05 UTC
According to the logs this is a unified sample. Can you try this using 8.2 (which has better unified support) ?

note: at this time there's no point in testing unified with anything older than 8.2 (fixes won't be backported to 8.0).
Comment 2 John Pilczak 2014-09-17 13:44:08 UTC
I just tested it and this issue still occurs in 8.2 as well. I will update the bug version to 8.2.

App output: https://gist.github.com/JohnPilczak/f7503455970846f38c02

Environment Info:
=== Xamarin Studio ===

Version 5.4 (build 236)
Installation UUID: ea2dde6b-0915-4e87-bf59-0163cddeada5
Runtime:
	Mono 3.8.0 ((no/45d0ba1)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 308000009

=== Apple Developer Tools ===

Xcode 6.0 (6299)
Build 6A313

=== Xamarin.iOS ===

Version: 8.2.0.154 (Business Edition)
Hash: 4df8cee
Branch: 
Build date: 2014-09-16 17:56:45-0400

=== Xamarin.Mac ===

Version: 1.11.0.1 (Starter Edition)

=== Build Information ===

Release ID: 504000236
Git revision: 7919b7498c2fbd22aa2f8beb7f5df597eceb742b
Build date: 2014-09-15 12:51:03-04
Xamarin addins: 209babcde541bd7445544f0a7bbd1b926e918297

=== Operating System ===

Mac OS X 10.9.4
Darwin Vinces-xMac.local 13.3.0 Darwin Kernel Version 13.3.0
    Tue Jun  3 21:27:35 PDT 2014
    root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
Comment 3 Sebastien Pouliot 2014-09-17 17:35:24 UTC
What's being given is a `UILayoutSupportWrapper` and the current helper code does not support that. IOW it's not unified related.
Comment 4 Sebastien Pouliot 2014-09-17 20:01:20 UTC
There's a few issues. First your code does not match Apple sample, i.e.:

        [newConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topLayoutGuide]-[nameLabel]-[conversationsLabel]-[photosLabel]-20-[imageView]|" options:0 metrics:nil views:views]];

versus:

				newConstraints.AddRange (NSLayoutConstraint.FromVisualFormat ("V:[topLayoutGuide]-[nameLabel]-[conversationsLabel]-[photosLabel]-20-[imageView]|",
					NSLayoutFormatOptions.DirectionLeadingToTrailing,
					"TopLayoutGuide", TopLayoutGuide,
					"nameLabel", NameLabel,
					"conversationsLabel", ConversationsLabel,
					"photosLabel", PhotosLabel,
					"imageView", ImageView));

a. "TopLayoutGuide" should be "topLayoutGuide" (a typo);

b. TopLayoutGuide (the property, not the string) is a `IUILayoutSupport`, IOW an interface, not an NSObject. So the internal cast fails and it tries to create a "metric" as an NSNumber (which is also invalid) leading to the exception
Comment 5 Sebastien Pouliot 2014-09-17 20:04:20 UTC
The "ugly" workaround is to call it this way:

				newConstraints.AddRange (NSLayoutConstraint.FromVisualFormat ("V:[topLayoutGuide]-[nameLabel]-[conversationsLabel]-[photosLabel]-20-[imageView]|",
					NSLayoutFormatOptions.DirectionLeadingToTrailing,
					"topLayoutGuide", ObjCRuntime.Runtime.GetNSObject (TopLayoutGuide.Handle),
					"nameLabel", NameLabel,
					"conversationsLabel", ConversationsLabel,
					"photosLabel", PhotosLabel,
					"imageView", ImageView));

i.e. get back the original `NSObject` represented by the IUILayoutSupport-wrapper.

I'm keeping the bug open (since it's ugly) but that should let you complete/test the sample.
Comment 6 Sebastien Pouliot 2014-09-17 20:46:44 UTC
The "ugly" part is already filled.

*** This bug has been marked as a duplicate of bug 21406 ***
Comment 7 Rustam Zaitov 2014-09-18 10:11:05 UTC
Thanks, Sebastien!
I applied fix to AdaptivePhotos sample
Comment 8 Miguel de Icaza [MSFT] 2014-09-18 11:47:35 UTC
I added support for passing our interfaces and turning those into the above call.
Comment 9 Miguel de Icaza [MSFT] 2014-09-18 11:48:27 UTC
De-duplicating, because the other issue is for a different API.
Comment 10 Rolf Bjarne Kvinge [MSFT] 2014-09-18 11:57:44 UTC
Rustam had an idea for a solution for the ugly part which I've implemented (special-cased to this FromVisualFormat overload), i.e. it will be possible to do this (instead of using GetNSObject):

          "topLayoutGuide", TopLayoutGuide,

maccore/master: c6a53404e7e093253b82bdbaf2f44e72cf101b25
monotouch/master: 5dfe31768667601064d341340c35ee2fc7ce9f1d
Comment 11 Rustam Zaitov 2014-09-18 11:59:30 UTC
Thanks, I fixed typo within "TopLayoutGuide" already.
Comment 14 Saurabh 2014-12-30 08:17:40 UTC
I have checked this Issue with iOS Simulator and iOS Devices. I am successfully able to click on Profile and it redirects to next view successfully. This is the screencast for the same: http://www.screencast.com/t/9kk2hrNd

=== Xamarin Studio ===

Version 5.7 (build 660)
Installation UUID: 2939b8b4-8977-42bd-82d6-100275ccd9cd
Runtime:
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.1 (6604)
Build 6A1052d

=== Xamarin.iOS ===

Version: 8.6.0.45 (Business Edition)
Hash: 0376f62
Branch: 
Build date: 2014-12-23 17:34:21-0500

=== Xamarin.Android ===

Version: 4.20.0.28 (Business Edition)
Android SDK: /Users/360_macmini/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		1.6   (API level 4)
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
		5.0   (API level 21)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

=== Xamarin.Mac ===

Version: 1.10.0.18 (Business Edition)

=== Build Information ===

Release ID: 507000660
Git revision: 6a74f9bdb90d9415b597064d815c9be38b401fee
Build date: 2014-12-18 00:38:00-05
Xamarin addins: 57be0f5e1433cb58b70ea9b52e9dc77ad791be40

=== Operating System ===

Mac OS X 10.9.4
Darwin 360-MACMINIs-Mac-mini-2.local 13.3.0 Darwin Kernel Version 13.3.0
    Tue Jun  3 21:27:35 PDT 2014
    root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64