Bug 1408 - App size is too big and Attempting to JIT compile method exception
Summary: App size is too big and Attempting to JIT compile method exception
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 4.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2011-10-11 00:18 UTC by Art
Modified: 2011-10-19 07:59 UTC (History)
2 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 FIXED

Description Art 2011-10-11 00:18:20 UTC
if I use link sdk assemblies only, I get "Attempting to JIT compile method" exception. It works fine on simulator. 

If I use don't link option, it works fine but the app size becomes around 38mb.
simulator size  : 7 mb.

I think the following code is throwing exception, if I don't use don't link

AttributeUsage(AttributeTargets.Method)]
  public class XmlRpcBeginAttribute : Attribute
  {




 mi = this.GetType().GetMethod(request.method);
      }
      // exceptions thrown during an MethodInfo.Invoke call are
      // package as inner of 
      Object reto;
      try
      {
        reto = mi.Invoke(this, request.args);
      }
Comment 1 Sebastien Pouliot 2011-10-11 08:44:30 UTC
Could you create a small, compilable (at least a complete method) test case that fails for sure, with the exception ? and also include the full message / stacktrace (in case it's not directly related to the method, but it's callers).

Thanks.
Comment 2 Art 2011-10-11 15:06:09 UTC
Please see the attached test file.

When I click on the test xml on device
ct 11 14:05:30 unknown kernel[0] <Debug>: launchd[2503] Container: /private/var/mobile/Applications/51EBBFD5-E4A6-4C77-A676-82148A3D6F27 [69] (sandbox)
Oct 11 14:05:31 unknown UIKitApplication:testapp[0xb225][2503] <Notice>: System.ExecutionEngineException: Attempting to JIT compile method '(wrapper remoting-invoke-with-check) testxml.WP:.ctor ()' while running with --aot-only.
Oct 11 14:05:31 unknown UIKitApplication:testapp[0xb225][2503] <Notice>:   at TestApp.TestAppViewController.Onclick (MonoTouch.Foundation.NSObject sender) [0x00000] in <filename unknown>:0 


 
Another issue not related : When I tap on the test photo button and try to scroll it crahes on
iOS 5 iPAd Device but not in simulator

 crash report for process TestApp[2494]
Oct 11 13:52:13 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:testapp[0x9f88]) Job appears to have crashed: Abort trap: 6
Oct 11 13:52:13 unknown SpringBoard[67] <Warning>: Application 'TestApp' exited abnormally with signal 6: Abort trap: 6
Oct 11 13:52:13 unknown ReportCrash[2497] <Error>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/TestApp_2011-10-11-135213_Green-Beans-iPad.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
Oct 11 13:54:13 unknown SpringBoard[67] <Notice>: Posting 'com.apple.iokit.hid.displayStatus' notifyState=0
Oct 11 13:54:13 unknown SpringBoard[67] <Notice>: MultitouchHID: detection mode: 0->255
Oct 11 13:59:23 unknown SpringBoard[67] <Notice>: Posting 'com.apple.iokit.hid.displayStatus' notifyState=1
Oct 11 13:59:23 unknown SpringBoard[67] <Notice>: MultitouchHID: detection mode: 255->0 (deferring until bootloaded)
Oct 11 13:59:23 unknown kernel[0] <Debug>: set_crc_notification_state 0
Oct 11 13:59:23 unknown SpringBoard[67] <Notice>: MultitouchHID: device bootloaded
Oct 11 13:59:23 unknown SpringBoard[67] <Notice>: MultitouchHID: detection mode: 0->0
Oct 11 14:01:25 unknown SpringBoard[67] <Notice>: Posting 'com.apple.iokit.hid.displayStatus' notifyState=0
Oct 11 14:01:25 unknown SpringBoard[67] <Notice>: MultitouchHID: detection mode: 0->255
Comment 4 Sebastien Pouliot 2011-10-17 08:36:57 UTC
test case provided in comment #3
Comment 5 Sebastien Pouliot 2011-10-17 10:38:38 UTC
Art, please fill a separate bug report for the "Test Photo" issue (you can link to the attachment in this bug report).
Comment 6 Sebastien Pouliot 2011-10-17 15:34:51 UTC
I think I've found the issue. Can you confirm to me that the (non linked) test case fails with:

testxml.XmlRpc.XmlRpcIllFormedXmlException: Response from server does not contain valid XML. ---> System.Xml.XmlException: Text node cannot appear in this state.  Line 1, position 1.
  at Mono.Xml2.XmlTextReader.ReadText (Boolean notWhitespace) [0x00000] in <filename unknown>:0 
  at Mono.Xml2.XmlTextReader.ReadContent () [0x00000] in <filename unknown>:0 
  at Mono.Xml2.XmlTextReader.Read () [0x00000] in <filename unknown>:0 
  at System.Xml.XmlTextReader.Read () [0x00000] in <filename unknown>:0 
  at System.Xml.XmlDocument.ReadNodeCore (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 
  at System.Xml.XmlDocument.ReadNode (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 
  at System.Xml.XmlDocument.Load (System.Xml.XmlReader xmlReader) [0x00000] in <filename unknown>:0 
  at testxml.XmlRpc.XmlRpcSerializer.DeserializeResponse (System.IO.Stream stm, System.Type svcType) [0x000a6] in /Users/sebastienpouliot/Downloads/Test/testxml/XmlRpcSerializer.cs:517 
  --- End of inner exception stack trace ---
  at testxml.XmlRpc.XmlRpcSerializer.DeserializeResponse (System.IO.Stream stm, System.Type svcType) [0x000c6] in /Users/sebastienpouliot/Downloads/Test/testxml/XmlRpcSerializer.cs:522 
  at testxml.XmlRpc.XmlRpcClientProtocol.ReadResponse (testxml.XmlRpc.XmlRpcRequest req, System.Net.WebResponse webResp, System.IO.Stream respStm, System.Type returnType) [0x00066] in /Users/sebastienpouliot/Downloads/Test/testxml/XmlRpcClientProtocol.cs:494 
  at testxml.XmlRpc.XmlRpcClientProtocol.Invoke (System.Object clientObj, System.Reflection.MethodInfo mi, System.Object[] parameters) [0x001f9] in /Users/sebastienpouliot/Downloads/Test/testxml/XmlRpcClientProtocol.cs:209 
  at testxml.XmlRpc.XmlRpcClientProtocol.Invoke (System.Object clientObj, System.String methodName, System.Object[] parameters) [0x0000a] in /Users/sebastienpouliot/Downloads/Test/testxml/XmlRpcClientProtocol.cs:119 
  at testxml.XmlRpc.XmlRpcClientProtocol.Invoke (System.String MethodName, System.Object[] Parameters) [0x00000] in /Users/sebastienpouliot/Downloads/Test/testxml/XmlRpcClientProtocol.cs:110 
  at testxml.WP.NewPost (Int32 blogid, System.String username, System.String password, Post content, Boolean publish) [0x00000] in /Users/sebastienpouliot/Downloads/Test/testxml/client/wordpress.cs:303 
  at testxml.WP.NewPost (Post content, Boolean publish) [0x00000] in /Users/sebastienpouliot/Downloads/Test/testxml/client/wordpress.cs:288 
  at TestApp.TestAppViewController.Onclick (MonoTouch.Foundation.NSObject sender) [0x00088] in /Users/sebastienpouliot/Downloads/Test/TestApp/TestAppViewController.cs:64 


as I now have the same behavior with linked (or not) application. Thanks!
Comment 7 Art 2011-10-17 20:52:25 UTC
Yes I am getting same error. Because it isn't not a valid username.
As long you aren't getting the "JIT compile method" error, it is working.

I found what is causing the image picker issue. iOS5 picker call back is in the different thread. I used InvokeOnMainthread and it working now.

Thanks
Art
Comment 8 Sebastien Pouliot 2011-10-18 09:03:14 UTC
Thanks for the confirmation. The issue comes from:

Missing method System.Runtime.Remoting.Messaging.ReturnMessage::.ctor(object,object[],int,LogicalCallContext,IMethodCallMessage) in assembly /Users/sebastienpouliot/Downloads/Test/TestApp/bin/iPhone/Debug/TestApp.app/mscorlib.dll, referenced in assembly /Users/sebastienpouliot/Downloads/Test/TestApp/bin/iPhone/Debug/TestApp.app/testxml.dll

that the linker eliminates since a large part of this code does not, under most circumtance, work properly  (without code generation) on iOS devices. That's an exception to the general rule. 

I'll add a linker option (in future MT releases) to disable the extra code removal. That will make .app larger than fully linked (but smaller than non-linked).

In the mean time you can try "Link SDK assemblies only" and add "--linkskip=mscorlib" in the "additional mtouch arguments". That will link every SDK assembly, except mscorlib (smaller app than non-linked, still larger than my fix will allow, but available right now :-).
Comment 9 Sebastien Pouliot 2011-10-18 11:30:38 UTC
8aa399cf257d65df3e11a10f8ea166209209848f (master)

Newer MonoTouch releases will allow you to specify "--nolinkaway" as an "additional mtouch arguments" (Project Options, iPhone Build) to get the best behavior.
Comment 10 Art 2011-10-18 22:48:41 UTC
I am not sure I posted this.
I tried using --linkskip=mscorlib"  but my app size is still more than 50mb.
will the new version make it smaller. The sim version of the app size is less than
7mb. I am not sure if it is related but I am getting the memory warning more often with iOS5 sdk. 

Thanks
Art
Comment 11 Art 2011-10-18 23:00:09 UTC
Hi,
I am sorry. I looked at the wrong dir. It is 18mb and working fine.

Thank you 
Art
Comment 12 Sebastien Pouliot 2011-10-19 07:59:46 UTC
Final size is hard to predict since it's application dependent (linker will only remove what's used). 

It should be between your current working, when --linkskip=mscorlib is used, size (18mb) and the unworking one, --linksdkonly (device builds, you can't compare to the simulator which uses the JIT versus AOT).