runtime: [regression/8.0.0] [iOS] After migration from net7.0-ios to net8.0-ios app crashes randomly in release mode with UseInterpreter="False"
Description
Sorry for the long explanation.
Due to my experience with migrations in the past, it was not planned to migrate to Maui NET8 soon. But after upgrading my Mac to Sonoma, i was forced, also to upgrade XCODE and i thought, it would be time, to update to the latest Maui Version as well.
I am working for a very long time (end of 2021) on a quite big and complex app and a solid foundation for more apps with MAUI in the future (?). My experience with Maui / Xamarin is much longer.
At the end of each development day, the iOS version is always tested on a real device in release mode. I set a high value on not being forced, to use the Interpreter in release mode and with an app in the store.
My release configuration:
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-ios|AnyCPU'">
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
<MtouchLink>SdkOnly</MtouchLink>
<UseInterpreter>False</UseInterpreter>
<ArchiveOnBuild>true</ArchiveOnBuild>
<CreatePackage>false</CreatePackage>
<CodesignEntitlement>Entitlements.plist</CodesignEntitlement>
<ProvisioningType>manual</ProvisioningType>
<CodesignProvision>The Profile</CodesignProvision>
<CodesignKey>The Key</CodesignKey>
</PropertyGroup>
My build command:
sudo dotnet publish TheApp.csproj -v d -c Release -f net8.0-ios /t:Run /p:RuntimeIdentifier=ios-arm64 /p:MtouchLink=SdkOnly /p:ArchiveOnBuild=True /p:00008101-001C49DC1E10001E
Although i try to keep my external dependencies at a very minimum, it does not work without some:
<ItemGroup>
<PackageReference Include="SkiaSharp" Version="2.88.6" />
<PackageReference Include="SkiaSharp.HarfBuzz" Version="2.88.6" />
<PackageReference Include="sqlite-net-pcl" Version="1.9.141-beta" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.6" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
<PackageReference Include="MediatR" Version="12.0.1" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.1.0" />
<PackageReference Include="LiveChartsCore.SkiaSharpView.Maui" Version="2.0.0-beta.800" />
<PackageReference Include="Camera.MAUI" Version="1.4.4" />
<PackageReference Include="Google.Apis.Drive.v3" Version="1.62.0.3155" />
</ItemGroup>
net7.0-ios
- Good: Debug mode - no crashes at runtime
- Good: Release mode with interpreter enabled - no crashes at runtime
- Good: Release mode with interpreter disabled - no crashes at runtime.
net8.0-ios (with the same code base)
- Good: Debug mode - no crashes at runtime
- Good: Release mode with interpreter enabled - no crashes at runtime
- BAD: Release mode with interpreter disabled - random crashes at runtime
It is now the fourth day, where i am trying to find the reason for that behaviour.
My results so far:
- Most of the time, it crashes without a stacktrace.
- When a stacktrace is produced, the top native entry is always the same
0x1079fdc10 - /private/var/containers/Bundle/Application/C04EAD60-C238-4588-A960-962F847CC77A/PublicStaging.app/TheApp : AppleCryptoNative_X509ImportCertificate
. . .
The top managed entry always shows the “InitializeComponent” method of a page
at TheApp.Module.AAA.ListPage:InitializeComponent <0x01338>
. . .
Because of the complex and deep hierarchy of custom UI-components, the app first crashed right at the start. I tried to narrow down the problem, by disabling some parts of the UI.
One of many, many, many, … experiments:
After some investigation, i randomly disabled a part in the UI, where i use a HorizontalStackLayout with BindableLayout.ItemsSource and suddenly, i could at least start the app. Of course, it crashed then in another part of the app.
Later i tried to replace this specific part of the UI with a CollectionView, and got some interesting results.
Setting the height of the CollectionView with the following code, does not crash:
HeightRequest="{StaticResource daterange_selector_height}"
...
<OnIdiom
x:Key="daterange_selector_height"
x:TypeArguments="x:Double"
Default="40"
Phone="34"
Tablet="34"/>
Setting the height of the CollectionView with this code, crashes immediately:
HeightRequest="34"
My questions are:
- What did change between net7.0-ios and net8.0-ios, that could explain this specific problem?
- Is there anything, i can do or any data i could provide?
- The process of debugging this class of errors is extremely frustrating and time consuming. Is there more information about tools or best practices?
Many thanks in advance!
Steps to Reproduce
Sorry, i tried to create a sample app to isolate the problem. But unfortunately it is not possible.
Link to public reproduction project repository
No response
Version with bug
8.0.0-rc.2.9373
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
7.0.96
Affected platforms
iOS
Affected platform versions
iOS 16.2
Did you find any workaround?
I tried, but no.
Relevant log output
No response
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 18 (11 by maintainers)
Great news
Tested with the full app.
Maui version
in release mode, with the following settings,
runs fast and without any crash.
Thank you very much for your work and time!
MAUI shipped an intermediate release yesterday: https://www.nuget.org/packages/Microsoft.NET.Sdk.Maui.Manifest-8.0.100-rc.2/8.0.0-rc.2.9511 with which I am not able to reproduce the crashes from any of the two scenarios you described in the
Test.md
file.Could you please try to update your MAUI workload to this newest version
8.0.0-rc.2.9511
and see if it helps?This can be done by doing:
To verify the version you can then:
Please let me know, if this helps/unblocks you, and I will continue investigating the root cause of the issues you were experiencing with the older version.
I can reproduce the crash, and it goes away if I disable LLVM:
The reason it only fails in the Release configuration is because we only enable LLVM by default in the Release configuration.
I’m going to move this to the dotnet/runtime repository, since this is a runtime/llvm issue.
I tested with .NET 8.0.100-rc.2.23502.2.
@SailDev Note that somebody other than me will take over from now, so you’ll have to send the project to them as well.
Can you try adding this to your csproj, that should provide better symbols for the native frames:
@rolfbjarne Can you please take a look? Thanks!