[iOS] Trimming / AOT issue after publish in .NET MAUI Blazor app
See original GitHub issueDescription
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
- Clone reproduction link
- Publish iOS and sign Ad Hoc / App Store
- Install app
- 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:
- Created 6 months ago
- Comments:12 (4 by maintainers)
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:
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.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.