Bug 9994 - Crash when user selects TextField inside a UIViewController, which is shown through PresentViewController()
Summary: Crash when user selects TextField inside a UIViewController, which is shown ...
Status: RESOLVED NORESPONSE
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 6.0.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-02-02 14:03 UTC by Dauren
Modified: 2013-12-05 18:34 UTC (History)
2 users (show)

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


Attachments
screenshot of a working keyboard (162.09 KB, image/png)
2013-02-02 14:31 UTC, Dauren
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 NORESPONSE

Description Dauren 2013-02-02 14:03:20 UTC
I call a UIViewController through PresentViewController() when button is pushed:

button1 = UIButton.FromType(UIButtonType.RoundedRect);
button1.SetTitle("hi", UIControlState.Normal);
button1.TouchUpInside += (sender, e) => {
	var s = new MApp.Screens.iPad.Email_PopupScreen(showEmail);
	s.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;
	viewCtrl.NavigationController.PresentViewController(s, false, null);
};



Email_PopupScreen is a simple "form view" from one of the MT.D samples that has ViewDidLoad() as follows:

public override void ViewDidLoad ()
{
	base.ViewDidLoad ();
	var element = new EntryElement ("test name", "Enter task description", "test description");
	var taskElement = new RootElement ("test")
	{
		new Section () { element },
		new Section () {
			new EntryElement ("add text", "text here", ""),
			new DateElement ("Due Date", new DateTime(2011, 11, 11, 11, 11, 11,DateTimeKind.Local))
		},
		new Section ("Demo Retrieving Element Value") {
			new StringElement ("Output Task Description",
			                   delegate { Console.WriteLine (element.Value); })
		},
		new Section ("Dinner") {
			new RootElement ("Dessert", new RadioGroup ("dessert", 2)) {
				new Section () {
						new RadioElement ("Ice Cream", "dessert"),
						new RadioElement ("Milkshake", "dessert"),
						new RadioElement ("Chocolate Cake", "dessert")
				}
			}
		}
	};

	DialogViewController _rootVC = new DialogViewController (taskElement);
	UINavigationController _nvc = new UINavigationController();
	_nvc.PushViewController(_rootVC, false);
	View.AddSubview(_nvc.View);
}



The form shows up fine, but when I click any TextField to bring up the keyboard I get the following error in output:



[ERROR] FATAL UNHANDLED EXCEPTION: System.Exception: Selector invoked from objective-c on a managed object of type MonoTouch.UIKit.UITextField+_UITextFieldDelegate (0x131E2D80) that has been GC'ed ---> System.MissingMethodException: No constructor found for MonoTouch.UIKit.UITextField+_UITextFieldDelegate::.ctor(System.IntPtr)
  at System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x000f1] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:280 
  at System.Activator.CreateInstance (System.Type type, System.Object[] args, System.Object[] activationAttributes) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:234 
  at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:229 
  at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (IntPtr ptr, IntPtr klass) [0x0000d] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:231 
  --- End of inner exception stack trace ---
  at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (IntPtr ptr, IntPtr klass) [0x00045] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:236 
  at MonoTouch.ObjCRuntime.Runtime.GetNSObject (IntPtr ptr) [0x0001f] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:280 
  at MonoTouch.ObjCRuntime.Runtime.GetNSObjectWrapped (IntPtr ptr) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:297 
  at (wrapper native-to-managed) MonoTouch.ObjCRuntime.Runtime:GetNSObjectWrapped (intptr)
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 
  at MApp.iOS.Application.Main (System.String[] args) [0x00000] in /Users/johnson/work/app/MApp/iOS/Main.cs:10 
Terminating runtime due to unhandled exception
Stacktrace:
Comment 1 Dauren 2013-02-02 14:31:40 UTC
Created attachment 3324 [details]
screenshot of a working keyboard

This behavior is not always reproducible. Sometimes when I restart MonoDevelop it starts to work fine, like on this screenshot. 

Then I stop the simulator and restart it again and I get a crash when I just try to click on the very first TextField.

I'll deploy this app to a real device and see if it can be reproduced there.
Comment 2 Rolf Bjarne Kvinge [MSFT] 2013-02-06 05:31:50 UTC
The UINavigationController (and thus the DialogViewController) are getting freed because nothing references it.

Try storing the UINavigationController in an instance field in the class instead of just a local variable in ViewDidLoad, that should fix it.
Comment 3 PJ 2013-11-19 17:04:26 UTC
This bug has been in the NEEDINFO state with no changes for the last 90 days. Can we put this back into the NEW or CONFIRMED state, or are we still awaiting response?

If there is no change in the status of this bug over the next two weeks, this bug will be marked as NORESPONSE.
Comment 4 PJ 2013-12-05 18:34:27 UTC
This bug has not been changed from the NEEDINFO state since my previous comment, marking as RESOLVED NORESPONSE.

Please feel free to REOPEN this bug at any time if you are still experiencing the issue. Please add the requested information and set the bug back to the NEW (or CONFIRMED) state.