App Crash using Hot Restart Xamarin Forms on iOS

2741
6
03-28-2021 08:25 PM
ChrisDalla_Piazza
New Contributor III

Hello,

Want to check if anyone has had success with the ArcGIS Runtime using Visual Studio Xamarin Forms on iOS using hot restart?

I created a new Xamarin Forms app for iOS in Visual Studio and added the following code in AppDelegate.cs

 

 

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
  global::Xamarin.Forms.Forms.Init();
  LoadApplication(new App());
  Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.Initialize();

  return base.FinishedLaunching(app, options);
}

 

 

 

The app launches and runs fine without the Initialize method on my iPhone.  It feels like I'm missing a dependency.

This is the error I get:

 

 

[0:] An error occurred: 'CoreRT_ArcGISRuntimeEnvironment_setInstallDirectory assembly:<unknown assembly> type:<unknown type> member:(null)'. Callstack: '  at (wrapper managed-to-native) RuntimeCoreNet.GeneratedWrappers.CoreArcGISRuntimeEnvironment.CoreRT_ArcGISRuntimeEnvironment_setInstallDirectory(byte[],intptr&)
  at RuntimeCoreNet.GeneratedWrappers.CoreArcGISRuntimeEnvironment.SetInstallDirectory (System.String installPath) <0x138775060 + 0x00010> in <2a33546a5b934b588629d4e33895c554>:0 
  at Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.InitNative () <0x1387748c8 + 0x00004> in <2a33546a5b934b588629d4e33895c554>:0 
  at Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.Initialize () <0x138774538 + 0x00042> in <2a33546a5b934b588629d4e33895c554>:0 
  at App1.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00013] in C:\Users\Chris\Documents\OnScene Xplorer\App1\App1.iOS\AppDelegate.cs:33 
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:86 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:65 
  at App1.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\Chris\Documents\OnScene Xplorer\App1\App1.iOS\Main.cs:17 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395 '

 

 

Looks like its attempting to make a call into a native method using DllImport.

I also tried the sample app from ArcGIS and it also fails the same way once I enable hot restart on it.

Any ideas for how to fix this?

Tags (3)
0 Kudos
6 Replies
ChrisDalla_Piazza
New Contributor III

More info...

The exception being thrown is EntryPointNotFoundException which means that the native call can't be resolved.

I did some sleuthing on my iPhone and found that runtimecore.dll and runtimecorenet.dll are not being copied to the deployment folder.  They also do not appear in the bin/Debug folder during build.  I believe those 2 dlls are the target of the native calls in Esri.ArcGISRuntime.dll.

So I think I have to figure out how to convince Visual Studio to include those in the iOS build.  I do see them being included in my UWP build.

0 Kudos
ChrisDalla_Piazza
New Contributor III

More info...

I checked the deployment folder on my iPhone. There is a native framework coming in from Nuget and it is making it onto the iPhone. It appears to be the target of the native call. In my UWP app, 2 dlls (runtimecore.dll and runtimecorenet.dll) appear to be the target of the native call.

[0:] File: /private/var/containers/Bundle/Application/5A23D747-9648-4727-8677-FB4E036F0343/App6.iOS.app/Frameworks/ArcGIS-arm64.framework/_CodeSignature/CodeResources
[0:] File: /private/var/containers/Bundle/Application/5A23D747-9648-4727-8677-FB4E036F0343/App6.iOS.app/Frameworks/ArcGIS-arm64.framework/ArcGIS-arm64
[0:] File: /private/var/containers/Bundle/Application/5A23D747-9648-4727-8677-FB4E036F0343/App6.iOS.app/Frameworks/ArcGIS-arm64.framework/Info.plist

 

I also see this in the verbose build output:

3>MtouchExtraArgs =  --framework:"${ProjectDir}/framework/ArcGIS-arm64.framework" --dynamic-symbol-mode=code

...

3>Task "AssignLinkMetadata" (TaskId:169)
3>  Task Parameter:
3>      Items=
3>          C:\Users\Chris\.nuget\packages\esri.arcgisruntime.runtimes.ios\100.10.0\buildTransitive\Xamarin.iOS10\..\..\framework\ArcGIS-arm64.framework\ArcGIS-arm64
3>                  CopyToOutputDirectory=PreserveNewest
3>                  Link=framework\ArcGIS-arm64.framework\ArcGIS-arm64
3>          C:\Users\Chris\.nuget\packages\esri.arcgisruntime.runtimes.ios\100.10.0\buildTransitive\Xamarin.iOS10\..\..\framework\ArcGIS-arm64.framework\Info.plist
3>                  CopyToOutputDirectory=PreserveNewest
3>                  Link=framework\ArcGIS-arm64.framework\Info.plist (TaskId:169)
3>Done executing task "AssignLinkMetadata". (TaskId:169)

I've read that native calls in iOS are static have to be built/compiled into the app. Do you know how I can check that this is happening correctly? Any idea what is going wrong with this native call?

Any help would be GREATLY appreciated. I would very much like to use my iPhone without a Mac to do dev on this project. Also don't want to commit to a Mac and then find the same problem!

0 Kudos
dotMorten_esri
Esri Notable Contributor

The ArcGIS-arm64.framework file is the iOS equivalent to runtimecore.dll and runtimecorenet.dll. I've recently seen issues with hot restart and framework files as well - it's my impression Xamarin.Forms recently broke this scenario and are following up with the Xamarin team.

0 Kudos
ChrisDalla_Piazza
New Contributor III

Thank you for the update. That is exciting news to see it should be working. 

Would there be a last known good version of Xamarin.Forms to fall back to?

0 Kudos
dotMorten_esri
Esri Notable Contributor

I believe you might be hitting this issue: https://github.com/xamarin/Xamarin.Forms/issues/13016

0 Kudos
ChrisDalla_Piazza
New Contributor III

I bumped into the segv issue while chasing this problem and do have an odd workaround for it.  Rename the folder containing the Visual Studio solution and it goes away!

My experience with the segv issue is it will show up during the course of rebuilds using hot restart.  An app that was working will suddenly start crashing.

I went ahead and created a TestFlight app for the original ArcGIS-arm64.framework issue and this works fine on the same device (iPhone 11) that I used to sideload the app using Hot Restart.  I also repro-ed the issue with Hot Restart yesterday using an up to date Visual Studio + Xamarin/ESRI Nuget packages.

I'm coming to the conclusion that Hot Restart is not a practical option for dev.

0 Kudos