question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[iOS] Trimming / AOT issue after publish in .NET MAUI Blazor app

See original GitHub issue

Description

I’m not sure if this issue should go here or under the dotnet/runtime, but the problem is following. MudBlazor users report problem when they publish app on iOS. Meanwhile, it runs normally in Debug / Release mode on the device. The problem is shown in the stack trace. I suspect that the setter property is getting removed and then SetParametersAsync -> ComponentProperties.SetProperties throws exception, because it’s using reflection to set the value. At first I thought it’s some MudBlazor trimming issue, but it’s not. The razor components are protected via Blazor framework, the RenderTreeBuilder, RootComponentMappingCollection etc are annotated with [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] and it should preserve everything in the component. Worth to mention that MudBlazor supports trimming in general, and it’s used by many people and there was never such problem encountered. The same code will work perfectly fine when used in Browser and published with trimming enabled!

If I’m not wrong, iOS has AOT compilation requirements, and maybe it’s way too aggressive. I should note that Blazor supports only partial TrimMode, but I’m not sure if MAUI uses ILLink as Blazor WASM does.

Additional information: Android is unaffected. Internal MudBlazor issue: https://github.com/MudBlazor/MudBlazor/issues/6310

Steps to Reproduce

  1. Clone reproduction link
  2. Publish iOS and sign Ad Hoc / App Store
  3. Install app
  4. Launch

Link to public reproduction project repository

https://github.com/QwertyMC/MauiBlazorTest

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 14 and higher

Did you find any workaround?

No. Seems ILLink.Descriptors.xml / BlazorLinkerDescriptor doesn’t have any effect.

Relevant log output

Unable to set property 'Required' on object of type 'MudBlazor.MudTextField`1[[System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]'. 
The error was: Attempting to JIT compile method '(wrapper delegate-invoke) void <Module>:invoke_callvirt_void_MudTextField`1<string>_bool (MudBlazor.MudTextField`1<string>,bool)' while running in aot-only mode. 
See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.
:    at Microsoft.AspNetCore.Components.Reflection.ComponentProperties.<SetProperties>g__SetProperty|3_0(Object target, PropertySetter writer, String parameterName, Object value)
   at Microsoft.AspNetCore.Components.Reflection.ComponentProperties.SetProperties(ParameterView& parameters, Object target)
   at Microsoft.AspNetCore.Components.ComponentBase.SetParametersAsync(ParameterView parameters)
   at MudBlazor.MudBaseInput`1[[System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<>n__1(ParameterView parameters)
   at MudBlazor.MudBaseInput`1.<SetParametersAsync>d__177[[System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()

Issue Analytics

  • State:closed
  • Created 6 months ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ScarletKurocommented, Mar 30, 2023

Thanks everyone for such fast help. Ok, I will close the issue since apparently there are multiple issues created, but what I would like to happen is:

  • The documentation gets improved and added to learn.microsoft. The UseInterpreter is a hard discoverable option. I found it in EF core issue, and I wasn’t sure what it’s doing from the name and if it’s AOT related. It’s also hard to find the drawbacks of using this option.
  • A better exception messages if applicable for this case.
  • Enabling interpreter by default when publishing on iOS since too many customers running into the problems rn.
  • Improve AOT in the future, so that it could AOT-compile such cases.
1reaction
ivanpovazancommented, Mar 30, 2023

This seems to be a duplicate of: https://github.com/dotnet/maui/issues/13279 and further: https://github.com/dotnet/runtime/issues/78889

There is a global tracking issue: https://github.com/dotnet/runtime/issues/83329 which would hopefully resolve all related issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Maui Blazor Publish Issue · Issue #13279 · dotnet/maui
When using mudblazor in a .NET 7 Maui Blazor iOS app, the app does not work when published to .ipa for use in...
Read more >
Native AOT deployment overview - .NET
Learn what native AOT deployments are and why you should consider using it as part of the publishing your app with .NET 7...
Read more >
Trimming options - .NET
Learn how to control trimming of self-contained apps.
Read more >
MAUI trim fails when publishing - android
I have a .net maui app that uses google maps. For the map on android side I use Xamarin.GooglePlayServices.Maps nuget. Problem is that ......
Read more >
Move to MAUI or move away? : r/dotnet
I'm just trying to push an Android and iOS app, nothing for desktop or web. How do you use Blazor for this? I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found