Bug 55054 - Calling NSRunLoop.Main.Perform makes it crash with 'unrecognized selector sent to instance'
Summary: Calling NSRunLoop.Main.Perform makes it crash with 'unrecognized selector sen...
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: Mono runtime / AOT compiler ()
Version: XI 10.8 (d15-1)
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Zoltan Varga
URL:
Depends on:
Blocks:
 
Reported: 2017-04-11 22:03 UTC by Evgeny
Modified: 2017-04-11 22:31 UTC (History)
3 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:
RESOLVED INVALID

Description Evgeny 2017-04-11 22:03:54 UTC
This seems to be only happening when running the app on iPhone4s iOS 9.3 simulator (i386 architecture, 32bit). Should be reproducible with the following code:

public class TestViewController : UIViewController
{
	public override void ViewDidAppear(bool animated)
	{
		base.ViewDidAppear(animated);

		NSRunLoop.Main.Perform(TestMethod);
	}

	public void TestMethod()
	{
	}
}

Exception stack:
2017-04-11 15:56:40.333 MyAppMobileiOS[25553:1578257] Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[NSRunLoop performBlock:]: unrecognized selector sent to instance 0x81559050
Native stack trace:
	0   CoreFoundation                      0x0964d494 __exceptionPreprocess + 180
	1   libobjc.A.dylib                     0x09ad3e02 objc_exception_throw + 50
	2   CoreFoundation                      0x09657253 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
	3   CoreFoundation                      0x0958c89d ___forwarding___ + 1037
	4   CoreFoundation                      0x0958c46e _CF_forwarding_prep_0 + 14
	5   MyAppMobileiOS                  0x0024f956 xamarin_dyn_objc_msgSend + 102
	6   ???                                 0x1a7c32cc 0x0 + 444347084
	7   ???                                 0x1b3f9668 0x0 + 457152104
	8   ???                                 0x1b3f24e6 0x0 + 457123046
	9   ???                                 0x1a03f317 0x0 + 436466455
	10  Mono                                0x005a1
2017-04-11 15:56:40.334 MyAppMobileiOS[25553:1578257] b68 mono_jit_runtime_invoke + 744
	11  Mono                                0x007639f6 do_runtime_invoke + 86
	12  Mono                                0x00763970 mono_runtime_invoke + 208
	13  MyAppMobileiOS                  0x00245b8f xamarin_invoke_trampoline + 6735
	14  MyAppMobileiOS                  0x0024f17c xamarin_arch_trampoline + 156
	15  MyAppMobileiOS                  0x0024f826 xamarin_i386_common_trampoline + 36
	16  UIKit                               0x018545fb -[UIViewController _setViewAppearState:isAnimating:] + 659
	17  UIKit                               0x01854aa3 __52-[UIViewController _setViewAppearState:isAnimating:]_block_invoke + 191
	18  CoreFoundation                      0x095774c9 __53-[__NSArrayI enumerateObjectsWithOptions:usingBlock:]_block_invoke + 73
	19  CoreFoundation                      0x09577362 -[__NSArrayI enumerateObjectsWithOptions:usingBlock:] + 162
	20  CoreFoundation                      0x09561f95 -[NSArray enumerateObjectsUsingBlock:] + 53
	21  U
2017-04-11 15:56:40.334 MyAppMobileiOS[25553:1578257] IKit                               0x01854853 -[UIViewController _setViewAppearState:isAnimating:] + 1259
	22  UIKit                               0x01854ceb -[UIViewController __viewWillAppear:] + 147
Comment 1 Evgeny 2017-04-11 22:28:53 UTC
Actually, it seems to be crashing on all iOS 9.3 simulators, not just iPhone 4s.
Comment 2 Evgeny 2017-04-11 22:31:38 UTC
Not a bug. NSRunLoop.Main.Perform is iOS 10+