Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aot compilation fail when publishing for iOS #8286

Closed
Ghevi opened this issue Jun 23, 2022 · 12 comments
Closed

Aot compilation fail when publishing for iOS #8286

Ghevi opened this issue Jun 23, 2022 · 12 comments
Labels
area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging partner/macios Issues for the Mac / iOS SDK platform/iOS 🍎 s/needs-repro Attach a solution or code which reproduces the issue t/bug Something isn't working

Comments

@Ghevi
Copy link

Ghevi commented Jun 23, 2022

Description

I'm trying to publish a maui app on a windows pc by pairing it with a Mac, with the command dotnet publish -f:net6.0-ios -c:Release
When the publishing reaches the step of Optimizing assemblies for size it remains stucked and eventually the connection with the Mac is interrupted. The process times out and other than this no other error appears.
In order to connect againt the two machines, I need to restart the Mac. This all happens on a windows machine.

So I tried to publish the app directly on the Mac from the Terminal with the same command prefixed by sudo.
This time the process reaches the same step and then give this error:

usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/15.4.311/targets/Xamarin.Shared.Sdk.targets(1000,3): error : Failed to AOT compile Microsoft.Identity.Client.dll, the AOT compiler exited with code 1 [/Users/MyUser/Desktop/MyApp/MyApp.csproj]

and in the same way it starts to hang at this point, slowing down the machine a lot and I need to terminate the process.
If i press ctrl + C, it tries to quit the compilation and these other lines are printed to the terminal that I have attached in the log output section.

Version with bug: 6.0.400-preview.22301.10

Steps to Reproduce

Publish for iOS with a windows machine and mac

Version with bug

Unknown/Other (please specify)

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS

Did you find any workaround?

No response

Relevant log output

` Tool /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.ios-arm64/6.0.6/Sdk/../tools/mono-aot-cross execution finished (exit code = 130).
Trying to cancel the compilation...
  Tool /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.ios-arm64/6.0.6/Sdk/../tools/mono-aot-cross execution finished (exit code = 130).
  Tool /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.ios-arm64/6.0.6/Sdk/../tools/mono-aot-cross execution finished (exit code = 130).      
  Tool /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.ios-arm64/6.0.6/Sdk/../tools/mono-aot-cross execution finished (exit code = 130).
...many other similar lines`

`/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/15.4.311/targets/Xamarin.Shared.Sdk.targets(1000,3): error : Failed to AOT compile Microsoft.Maui.dll, the AOT compiler exited with code 130 [csproj path ] 
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/15.4.311/targets/Xamarin.Shared.Sdk.targets(1000,3): error : Failed to AOT compile Microsoft.Extensions.FileProviders.Composite.dll, the AOT compiler exited with code 130 
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/15.4.311/targets/Xamarin.Shared.Sdk.targets(1000,3): error : Failed to AOT compile System.Security.Cryptography.Primitives.dll, the AOT compiler exited with code 130 
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/15.4.311/targets/Xamarin.Shared.Sdk.targets(1000,3): error : Failed to AOT compile System.Security.Cryptography.Algorithms.dll, the AOT compiler exited with code 130 
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/15.4.311/targets/Xamarin.Shared.Sdk.targets(1000,3): error : Failed to AOT compile System.Text.Encoding.CodePages.dll, the AOT compiler exited with code 130 
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/15.4.311/targets/Xamarin.Shared.Sdk.targets(1000,3): error : Failed to AOT compile System.ObjectModel.dll, the AOT compiler exited with `
@Ghevi Ghevi added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Jun 23, 2022
@PureWeen
Copy link
Member

@Ghevi can you upload a reproduction to github please?

@PureWeen PureWeen added s/needs-repro Attach a solution or code which reproduces the issue and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Jun 23, 2022
@ghost
Copy link

ghost commented Jun 23, 2022

Hi @Ghevi. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

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.

@Ghevi
Copy link
Author

Ghevi commented Jun 23, 2022

@PureWeen i can't upload the whole project, but I could try to make a new one, try publishing that to exclude it's not an issue on my environment, then try with the same packages that i'm using in the affected app.
Is there a way to publish a new project quickly as test without all the steps for the apple store process like certificates, provision file etc?

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels Jun 23, 2022
@Ghevi
Copy link
Author

Ghevi commented Jun 24, 2022

@PureWeen so i tried publishing a brand new project, first with Maui Blazor and then Maui. Both still presented the same issue.
So I tried some combination of enabling and disabling Aot Compilation and LLVM optimization.

This didn't work
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-ios|AnyCPU'">
<MtouchUseLlvm>True</MtouchUseLlvm>
<AotAssemblies>False</AotAssemblies>
</PropertyGroup>

This did work
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-ios|AnyCPU'">
<MtouchUseLlvm>False</MtouchUseLlvm>
<AotAssemblies>True</AotAssemblies>
</PropertyGroup>

So the issue seems to be the LLVM optimization...
Could it be related to this even tho they have this issue on android?
xamarin/xamarin-android#6792
xamarin/xamarin-android#6777
Are you able to test it yourself on a new test project? Or do You still want me to upload a repo?

@Eilon Eilon added the area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging label Jun 24, 2022
@rmarinho rmarinho added partner/macios Issues for the Mac / iOS SDK and removed s/needs-attention Issue has more information and needs another look labels Jul 21, 2022
@chamons
Copy link

chamons commented Jul 21, 2022

Thanks for the feedback @Ghevi

I tried reproducing your issue with a new ios and a new maui project with this set:

	<MtouchUseLlvm>True</MtouchUseLlvm>
	<AotAssemblies>False</AotAssemblies

and I was unable to. Attaching a repro would be very useful.

@Ghevi
Copy link
Author

Ghevi commented Jul 22, 2022

@chamons
I'm sorry I can't share the repro right now, I understand that it's very useful, so I will attach one if I manage to reproduce the issue on a new app.
Worth noting that since my previous comment, a similar issue started to happen in Android too, similar to #8337.

Things I've tried on Android:

  • Creating a brand new maui app and enabling the Aot worked fine. So if You can't reproduce the issue on iOS, I think it might have to something with my project.
  • Adding the same nuget packages on the new app didn't cause the issue.
  • Since I've localization .resx files on a class library project, i added their reference and used some of the translations but this didn't cause the issue either.

Will try again on iOS too...
Thank you for the help!

@dalexsoto dalexsoto added the s/needs-repro Attach a solution or code which reproduces the issue label Jul 22, 2022
@ghost
Copy link

ghost commented Jul 22, 2022

Hi @Ghevi. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

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.

@ghost ghost added the s/no-recent-activity Issue has had no recent activity label Jul 26, 2022
@ghost
Copy link

ghost commented Jul 26, 2022

This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@Alby-o
Copy link

Alby-o commented Jul 27, 2022

I'm getting this issue when I've referenced a project in my MAUI application that has a private asset project reference.

MAUI project:

<Project Sdk="Microsoft.NET.Sdk.Razor">

	<PropertyGroup>
		<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
		<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
		<OutputType>Exe</OutputType>
		<RootNamespace>MyMauiProject</RootNamespace>
		<UseMaui>true</UseMaui>
		<SingleProject>true</SingleProject>
		<ImplicitUsings>enable</ImplicitUsings>
		<EnableDefaultCssItems>false</EnableDefaultCssItems>

		<!-- Display name -->
		<ApplicationTitle>Application</ApplicationTitle>

		<!-- App Identifier -->
		<ApplicationId>com.company.application</ApplicationId>
		<ApplicationIdGuid>0000000-0000-0000-0000-000000000000</ApplicationIdGuid>

		<!-- Versions -->
		<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
		<ApplicationVersion>1</ApplicationVersion>

		<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
		<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
		<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">23.0</SupportedOSPlatformVersion>
		<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
		<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
	</PropertyGroup>
	
	<ItemGroup>
		<!-- App Icon -->
		<MauiIcon Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" Color="#2E3643" />

		<!-- Splash Screen -->
		<MauiSplashScreen Include="Resources\logo.svg" Color="#2E3544" />
	</ItemGroup>

	<ItemGroup>
		<ProjectReference Include="..\MyReferencedProject\MyReferencedProject.csproj" />
	</ItemGroup>
</Project>

Referenced Project:

<Project Sdk="Microsoft.NET.Sdk">

	<PropertyGroup>
		<TargetFramework>net6.0</TargetFramework>
		<ImplicitUsings>enable</ImplicitUsings>
	</PropertyGroup>

	<ItemGroup>
		<ProjectReference Include="..\AnotherProject\AnotherProject.csproj" PrivateAssets="All" />
	</ItemGroup>
</Project>

PrivateAsset Project:

<Project Sdk="Microsoft.NET.Sdk">

	<PropertyGroup>
		<TargetFramework>net6.0</TargetFramework>
		<ImplicitUsings>enable</ImplicitUsings>
	</PropertyGroup>
	
	<ItemGroup>
		<PackageReference Include="NuGetPackage" Version="1.0.0" />
	</ItemGroup>
</Project>

Then fails with:

Tool /Users/runner/hostedtoolcache/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.ios-arm64/6.0.7/Sdk/../tools/mono-aot-cross execution finished (exit code = 1).
                 
         Mono Ahead of Time compiler - compiling assembly /Users/runner/work/1/s/MyMauiProject/obj/Release/net6.0-ios/ios-arm64/linked/AnotherProject.dll
         AOTID F7FDC28D-6BDE-B628-E4BB-9D152986E32E
         Failed to load method 0x6000004 from '/Users/runner/work/1/s/MyMauiProject/obj/Release/net6.0-ios/ios-arm64/linked/AnotherProject.dll' due to Could not load file or assembly 'NuGetPackage, Version=1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies..
         Run with MONO_LOG_LEVEL=debug for more information.
         AOT of image /Users/runner/work/1/s/MyMauiProject/obj/Release/net6.0-ios/ios-arm64/linked/AnotherProject.dll failed.
       

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue s/no-recent-activity Issue has had no recent activity labels Jul 27, 2022
@chamons chamons added s/needs-repro Attach a solution or code which reproduces the issue and removed s/needs-attention Issue has more information and needs another look labels Jul 27, 2022
@ghost
Copy link

ghost commented Jul 27, 2022

Hi @Ghevi. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

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.

@chamons
Copy link

chamons commented Jul 27, 2022

Thanks for the information @Alby-o but unfortunately that's not a repro that we can use to dig into this. We need an actual executable project to dig into why the AOT compiler is failing.

@ghost ghost added the s/no-recent-activity Issue has had no recent activity label Aug 1, 2022
@ghost
Copy link

ghost commented Aug 1, 2022

This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@ghost ghost closed this as completed Aug 4, 2022
@dotnet dotnet locked as resolved and limited conversation to collaborators Sep 3, 2022
@ghost ghost removed the s/no-recent-activity Issue has had no recent activity label Feb 1, 2024
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging partner/macios Issues for the Mac / iOS SDK platform/iOS 🍎 s/needs-repro Attach a solution or code which reproduces the issue t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants