xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.46k stars 511 forks source link

Can’t launch the application in release mode after updates #19373

Closed PodopryhoraAnita closed 11 months ago

PodopryhoraAnita commented 11 months ago

Steps to Reproduce

Hello everyone, MacOS, XCode, VS for mac have been updated and the project is stuck with this error:

Xamarin.Hosting: Loaded Xcode plugins successfully. Xamarin.Hosting: Device discovery started Xamarin.Hosting: Device discovery event: GizmoPaired (00008301-E0966CD93C80C02E) Xamarin.Hosting: Device discovery event: Connected (00008120-0014350C36E0C01E) Xamarin.Hosting: Connected to iPhone (Anita) (00008120-0014350C36E0C01E) in 00:00:00.0217707 Xamarin.Hosting: Device discovery event: Connected (00008120-0014350C36E0C01E) Xamarin.Hosting: Device discovery event: GizmoPaired (00008301-E0966CD93C80C02E) Xamarin.Hosting: Connected to iPhone (Anita) (00008120-0014350C36E0C01E) in 00:00:00.0013638 warning MT1043: Failed to launch the application using the instruments service. Will try launching the app using gdb service.

--- inner exception error HE0032: Could not mount developer tools on 'iPhone (Anita)': Object reference not set to an instance of an object


--- inner exception System.NullReferenceException: Object reference not set to an instance of an object at Xamarin.Hosting.RealDevice.ConnectToken () [0x0008a] in /Users/builder/azdo/_work/1/s/tools/mlaunch/Xamarin.Hosting/Xamarin.Hosting/RealDevice.cs:110 at System.Threading.Tasks.Task.InnerInvoke () [0x0000f] in /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/src/Xamarin.Mac/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2476 at System.Threading.Tasks.Task.Execute () [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/src/Xamarin.Mac/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2319 --- End of stack trace from previous location where exception was thrown ---

at Xamarin.Hosting.RealDevice.MountDeveloperDiskImageAsync () [0x00098] in /Users/builder/azdo/_work/1/s/tools/mlaunch/Xamarin.Hosting/Xamarin.Hosting/RealDevice.cs:648

Launching 'com.ugv.UGVChargers' on the device 'iPhone (Anita)' error MT0000: Unexpected error - Please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new error HE0032: Could not mount developer tools on 'iPhone (Anita)': Object reference not set to an instance of an object

Expected Behavior

The application must be launched in release mode

Actual Behavior

The application does not launch in release mode, but works in debug mode only by tapping, I tried to create new app in Xcode and launch it on my Phone and it worked well Also tried to reboot my phone and Mac, delete bin/obj, but it doesn't work

Environment

I use Xcode 15.0.1, VSMac 17.6.6 ,Xamarin.iOS Version: 16.4.0.18, macOS Sonoma 14.1

dalexsoto commented 11 months ago

This has been fixed in the latest iOS workload and also in Xamarin.iOS which is pending release. You can manually install this package in the meantime.

https://download.visualstudio.microsoft.com/download/pr/0b7c2f36-ec7c-4bf2-a7a3-772dfcf1c92d/20af132da3385f774b198f188b4636c3/xamarin.ios-16.4.0.22.pkg

PodopryhoraAnita commented 11 months ago

This has been fixed in the latest iOS workload and also in Xamarin.iOS which is pending release. You can manually install this package in the meantime.

https://download.visualstudio.microsoft.com/download/pr/0b7c2f36-ec7c-4bf2-a7a3-772dfcf1c92d/20af132da3385f774b198f188b4636c3/xamarin.ios-16.4.0.22.pkg

@dalexsoto Unfortunately, it doesn't work for me, app still doesn't launch on release mode

rolfbjarne commented 11 months ago

@dalexsoto Unfortunately, it doesn't work for me, app still doesn't launch on release mode

Are you saying that tapping on the app on the device doesn't work for a release build?

PodopryhoraAnita commented 11 months ago

@rolfbjarne yes

rolfbjarne commented 11 months ago

OK, the logs/errors in the description is a red herring then, that's an unrelated issue (which we've fixed), but it shouldn't affect launching the app by tapping on it.

However, that means we'll more information in order to figure out what's going on:

PodopryhoraAnita commented 11 months ago

@rolfbjarne all is here logs.zip

rolfbjarne commented 11 months ago

Some of the crash reporst look like this:

Thread 0 Crashed:
0   libsystem_kernel.dylib                 0x1fbc3d01c __pthread_kill + 8
1   libsystem_pthread.dylib                0x21e246680 pthread_kill + 267
2   libsystem_c.dylib                      0x1bd03bc44 __abort + 135
3   libsystem_c.dylib                      0x1bd03bbbc abort + 191
4   UGVChargers.iOS                        0x103d7bc1c xamarin_unhandled_exception_handler + 60
5   UGVChargers.iOS                        0x103c4346c mono_invoke_unhandled_exception_hook + 132
6   UGVChargers.iOS                        0x103bd8564 mono_handle_exception_internal + 5664
7   UGVChargers.iOS                        0x103bd6f38 mono_handle_exception + 56
8   UGVChargers.iOS                        0x103bccc30 mono_arm_throw_exception + 360
9   UGVChargers.iOS                        0x10180580c rethrow_exception + 172
10  UGVChargers.iOS                        0x10150a6d4 wrapper_managed_to_native_System_MonoCustomAttrs_GetCustomAttributesInternal_System_Reflection_ICustomAttributeProvider_System_Type_bool + 196
11  UGVChargers.iOS                        0x10150ab34 System_MonoCustomAttrs_GetCustomAttributesBase_System_Reflection_ICustomAttributeProvider_System_Type_bool + 116
12  UGVChargers.iOS                        0x10150ac3c System_MonoCustomAttrs_GetCustomAttributes_System_Reflection_ICustomAttributeProvider_System_Type_bool + 108
13  UGVChargers.iOS                        0x1015c2424 System_Reflection_RuntimeAssembly_GetCustomAttributes_System_Type_bool + 36
14  UGVChargers.iOS                        0x1014e25bc System_Attribute_GetCustomAttributes_System_Reflection_Assembly_System_Type_bool + 156
15  UGVChargers.iOS                        0x1014e2510 System_Attribute_GetCustomAttributes_System_Reflection_Assembly_System_Type + 32
16  UGVChargers.iOS                        0x1015baf0c System_Reflection_CustomAttributeExtensions_GetCustomAttributes_System_Reflection_Assembly_System_Type + 28
17  UGVChargers.iOS                        0x1033643d0 Xamarin_Forms_Xaml_XamlParser_GatherXmlnsDefinitionAttributes + 240
18  UGVChargers.iOS                        0x1033646a8 Xamarin_Forms_Xaml_XamlParser_GetElementType_Xamarin_Forms_Xaml_XmlType_System_Xml_IXmlLineInfo_System_Reflection_Assembly_Xamarin_Forms_Xaml_XamlParseException_ + 232
19  UGVChargers.iOS                        0x1033689e0 Xamarin_Forms_Xaml_Internals_XamlTypeResolver_TryResolve_Xamarin_Forms_Xaml_XmlType_System_Type_ + 64
20  UGVChargers.iOS                        0x10334d550 Xamarin_Forms_Xaml_ExpandMarkupsVisitor_MarkupExpansionParser_Parse_string_string__System_IServiceProvider + 2768
21  UGVChargers.iOS                        0x10334c3ac Xamarin_Forms_Xaml_ExpandMarkupsVisitor_ParseExpression_string__System_Xml_IXmlNamespaceResolver_System_Xml_IXmlLineInfo_Xamarin_Forms_Xaml_INode_Xamarin_Forms_Xaml_INode + 908
22  UGVChargers.iOS                        0x10334be50 Xamarin_Forms_Xaml_ExpandMarkupsVisitor_Visit_Xamarin_Forms_Xaml_MarkupNode_Xamarin_Forms_Xaml_INode + 384
23  UGVChargers.iOS                        0x10335f404 Xamarin_Forms_Xaml_MarkupNode_Accept_Xamarin_Forms_Xaml_IXamlNodeVisitor_Xamarin_Forms_Xaml_INode + 68
24  UGVChargers.iOS                        0x10335f96c Xamarin_Forms_Xaml_ElementNode_Accept_Xamarin_Forms_Xaml_IXamlNodeVisitor_Xamarin_Forms_Xaml_INode + 300
25  UGVChargers.iOS                        0x10335fa14 Xamarin_Forms_Xaml_ElementNode_Accept_Xamarin_Forms_Xaml_IXamlNodeVisitor_Xamarin_Forms_Xaml_INode + 468
26  UGVChargers.iOS                        0x10335fa14 Xamarin_Forms_Xaml_ElementNode_Accept_Xamarin_Forms_Xaml_IXamlNodeVisitor_Xamarin_Forms_Xaml_INode + 468
27  UGVChargers.iOS                        0x1033603fc Xamarin_Forms_Xaml_RootNode_Accept_Xamarin_Forms_Xaml_IXamlNodeVisitor_Xamarin_Forms_Xaml_INode + 300
28  UGVChargers.iOS                        0x10335d718 Xamarin_Forms_Xaml_XamlLoader_Visit_Xamarin_Forms_Xaml_RootNode_Xamarin_Forms_Xaml_HydrationContext_bool + 456
29  UGVChargers.iOS                        0x10335bc48 Xamarin_Forms_Xaml_XamlLoader_Load_object_string_System_Reflection_Assembly_bool + 1416
30  UGVChargers.iOS                        0x10335b668 Xamarin_Forms_Xaml_XamlLoader_Load_object_string_bool + 40
31  UGVChargers.iOS                        0x10335b598 Xamarin_Forms_Xaml_XamlLoader_Load_object_System_Type + 104
32  UGVChargers.iOS                        0x10335b1f0 Xamarin_Forms_Xaml_Extensions_LoadFromXaml_TXaml_REF_TXaml_REF_System_Type + 32
33  UGVChargers.iOS                        0x102853f6c UGVChargers_App_InitializeComponent + 44
34  UGVChargers.iOS                        0x10284d728 UGVChargers_App__ctor + 104
35  UGVChargers.iOS                        0x101413518 UGVChargers_IOS_AppDelegate_FinishedLaunching_UIKit_UIApplication_Foundation_NSDictionary + 968
36  UGVChargers.iOS                        0x1017c43a0 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 272
37  UGVChargers.iOS                        0x103bea328 mono_jit_runtime_invoke + 1136

which indicates that an unhandled exception caused the process to terminate.

Usually the device log shows the exception info, but nothing shows up. Did you open the Console app and start streaming the device log before triggering the launch crash? The device log won't show anything that's happened before you opened it.

PodopryhoraAnita commented 11 months ago

@rolfbjarne I opened the Console before start streaming, I sent u another two logs file, first one during building app and launch from VS for Mac and another one logs from launch app with tapp logs.zip maybe it will helpful

rolfbjarne commented 11 months ago

That didn't help unfortunately.

Can you try enabling the interpreter in the csproj to see if that fixes the problem?

<PropertyGroup>
    <UseInterpreter>true</UseInterpreter>
</PropertyGroup>

If that doesn't work, we'll need a test project we can use to reproduce the problem in order to track it down.

PodopryhoraAnita commented 11 months ago

@rolfbjarne I enabled the interpreter but it didn't fix the problem how could I give u the test project?

rolfbjarne commented 11 months ago

@rolfbjarne I enabled the interpreter but it didn't fix the problem how could I give u the test project?

If it's a private project, you can do this:

  1. Create a new feedback ticket here: https://developercommunity.visualstudio.com/VisualStudioMac/report, saying it's only to provide private data (add a link to this issue).
  2. Zip up and attach the project as a private attachment.
  3. Add a comment here with a link to the feedback ticket.
PodopryhoraAnita commented 11 months ago

@rolfbjarne my zip file size is 4 Gb , allowed size is only 2gb, I can't upload zip file how can I send u file in another way?

rolfbjarne commented 11 months ago

@PodopryhoraAnita if you clean your project and/or remove the bin/obj directories the size should shrink significantly.

PodopryhoraAnita commented 11 months ago

I did it, this zip without bin/obj

rolfbjarne commented 11 months ago

I did it, this zip without bin/obj

Are you saying the file is 4gb without the bin/obj directories?

In any case, you can also use a file-sharing service like Dropbox if that's easier.

PodopryhoraAnita commented 11 months ago

https://www.dropbox.com/scl/fi/nad81ocve1cwo3g04v25f/Chargers.zip?rlkey=4wuv8b5l2iydjgkuq948uiuma&dl=0 could u try Dropbox, please

rolfbjarne commented 11 months ago

I get a startup crash like this, but it doesn't look like the crash you're having, so it might be something else:

Unhandled Exception:
System.InvalidOperationException: Sequence contains no elements
  at System.Linq.Enumerable.Last[TSource] (System.Collections.Generic.IEnumerable`1[T] source) <0x1054c5620 + 0x00058> in <112d715759634cb18dc70888cd90afca#179cccc51f26e3e5e00fef3e7eef3c8d>:0
  at UGVChargers.App.OnResume () <0x106130e90 + 0x000df> in <dece1de62e9148cab4c3c20ee955e3bc#179cccc51f26e3e5e00fef3e7eef3c8d>:0
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) <0x104f026a0 + 0x00053> in <aae03b95719e488f8a163bae4d2b5dcb#179cccc51f26e3e5e00fef3e7eef3c8d>:0
  at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () <0x105cb9090 + 0x0002b> in <0858f891071849cebbc0ed5278a7d77a#179cccc51f26e3e5e00fef3e7eef3c8d>:0
  at (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,intptr,intptr,intptr,intptr&)
  at UIKit.UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName) <0x105cf1020 + 0x0004b> in <0858f891071849cebbc0ed5278a7d77a#179cccc51f26e3e5e00fef3e7eef3c8d>:0
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) <0x105cf1130 + 0x0005f> in <0858f891071849cebbc0ed5278a7d77a#179cccc51f26e3e5e00fef3e7eef3c8d>:0
  at UGVChargers.IOS.Application.Main (System.String[] args) <0x104d87ac0 + 0x00023> in <6001aa0f90164959bb4f134f5697cad8#179cccc51f26e3e5e00fef3e7eef3c8d>:0

My suggestion would be for you to try to get the console output from the app as it launches on the device.

This can be done by launching the app on the device using the command line on the Mac:

  1. Build the app using the Release configuration (or whichever configuration you want to test).
  2. Open a terminal window, and go to the project's directory:
$ cd path/to/Chargers/MobileApp/MobileApp.iOS
  1. Execute the mlaunch tool like this to list the devices connected to the Mac, and take note of the UUID of the device you want to use.
$ /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mlaunch --listdev
Rolf's iPhone 12: UUID
  1. Execute mlaunch to install the app (replace UUID with the value from step 3):
$ /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mlaunch --installdev bin/iPhone/Release/UGVChargers.iOS.app --devname UUID
  1. Execute mlaunch to launch the app (replace UUID with the value from step 3):
$ /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mlaunch --launchdev bin/iPhone/Release/UGVChargers.iOS.app --devname UUID --wait-for-exit -vvvv

You should now get the output from the app in the terminal, this will hopefully include the stack trace for the unhandled exception you're seeing.

PodopryhoraAnita commented 11 months ago

Here all that I got from terminal log1.txt log2.txt

rolfbjarne commented 11 months ago

Looks like you're in the wrong directory in the terminal, because the error message is (trying to) say that the directory bin/iPhone/Release/UGVChargers.iOS.app doesn't exist.

What does this show?

$ ls -la
$ ls -la bin/iPhone/Release/UGVChargers.iOS.app
$ find .
PodopryhoraAnita commented 11 months ago
$ ls -la
total 119000
drwxr-xr-x  16 root  wheel       512 Oct 19 08:30 .
drwxr-xr-x  11 root  wheel       352 Oct 19 06:37 ..
-rwxr-xr-x   1 root  wheel  10070432 Nov  8 12:24 arm-darwin-mono-sgen
-rwxr-xr-x   1 root  wheel  10020768 Nov  8 12:24 arm64-darwin-mono-sgen
-rwxr-xr-x   1 root  wheel  10004208 Nov  8 12:24 arm64_32-darwin-mono-sgen
-rwxr-xr-x   1 root  wheel  10087216 Nov  8 12:24 armv7k-unknown-darwin-mono-sgen
-rwxr-xr-x   1 root  wheel       207 Nov  8 12:24 bgen
-rwxr-xr-x   1 root  wheel       183 Nov  8 12:24 btouch
-rwxr-xr-x   1 root  wheel       243 Nov  8 12:24 btouch-native
-rwxr-xr-x   1 root  wheel       244 Nov  8 12:24 btv
-rwxr-xr-x   1 root  wheel       247 Nov  8 12:24 bwatch
-rwxr-xr-x   1 root  wheel       165 Nov  8 12:24 mlaunch
-rwxr-xr-x   1 root  wheel       211 Nov  8 12:24 mtouch
-rwxr-xr-x   1 root  wheel  10045360 Nov  8 12:24 simlauncher32-sgen
-rwxr-xr-x   1 root  wheel  10655040 Nov  8 12:24 simlauncher64-sgen
-rwxr-xr-x   1 root  wheel        90 Nov  8 12:24 smcs

$ ls -la bin/iPhone/Release/UGVChargers.iOS.app
ls: bin/iPhone/Release/UGVChargers.iOS.app: No such file or directory
rolfbjarne commented 11 months ago

Step 2 didn't complete successfully:

$ cd path/to/Chargers/MobileApp/MobileApp.iOS

you need to change "path/to" to the actual local path where your project is located.

PodopryhoraAnita commented 11 months ago

Like that? log.txt

rolfbjarne commented 11 months ago

Yes, now try:

$ /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mlaunch --installdev bin/iPhone/Release/UGVChargers.iOS.app --devname 00008120-001435

and

$ /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mlaunch --launchdev bin/iPhone/Release/UGVChargers.iOS.app --devname 00008120-0014350 --wait-for-exit -vvvv
PodopryhoraAnita commented 11 months ago

log.txt

rolfbjarne commented 11 months ago

I forgot that Apple changes things in iOS 17, so now we don't get stdout/stderr from the app anymore :/

Would you happen to have a device you can test with that hasn't been upgraded to iOS 17 (still using iOS 16 for instance)?

PodopryhoraAnita commented 11 months ago

I could continue to use simulators, but as I understand , I can no longer submit the application to TestFlight, and my test group no longer has access to the application, is there any way to submit new builds of the application to TestFlight?

rolfbjarne commented 11 months ago

I could continue to use simulators, but as I understand , I can no longer submit the application to TestFlight, and my test group no longer has access to the application, is there any way to submit new builds of the application to TestFlight?

If only the Debug build works on device, you could try submitting a Debug build to TestFlight until you figure out the problem with the Release build.

For further diagnosis, I would recommend trying to change the Release project configuration setting by setting to try to match the Debug configuration, in order to figure out exactly which project configuration is causing the problem.

PodopryhoraAnita commented 11 months ago

my application is published to TestFlight with release build, but after installation it cannot be launched launching an application with debug build is only available with package version 16.4.0.18, but I cannot publish the application with debug build in TestFlight will this be fixed in future xamarin packages?

rolfbjarne commented 11 months ago

will this be fixed in future xamarin packages?

I don't know, since I don't know why the app isn't working, which is why I'm asking questions trying to figure that out.

As in my previous comment, I'd recommend trying to figure out exactly why the Release configuration is different by trying to make it like the Debug configuration one setting at a time.

PodopryhoraAnita commented 11 months ago

Hello, I tried to make configuration Release like Debug step by step, and now it looks almost the same, but app still does't launch Do u have any idea how to resolve this problem ? configuration.txt

rolfbjarne commented 11 months ago

Can you try making sure the MtouchFloat32, MtouchFastDev and MtouchExtraArgs properties are identical between Debug and Release as well?

microsoft-github-policy-service[bot] commented 11 months ago

Hi @PodopryhoraAnita. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

microsoft-github-policy-service[bot] commented 11 months ago

Hi @PodopryhoraAnita. Due to inactivity, we will be closing this issue. Please feel free to re-open this issue if the issue persists. For enhanced visibility, if over 7 days have passed, please open a new issue and link this issue there. Thank you.