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

Release System.ExecutionEngineException Blazor Hybrid iOS ComponentProperties.SetProperties(in ParameterView, object)+SetProperty(object, PropertySetter, string, object) #74015

Closed
Kylar182 opened this issue Aug 12, 2022 · 25 comments
Assignees
Milestone

Comments

@Kylar182
Copy link

Kylar182 commented Aug 12, 2022

Description

having a Release only issue with Components on MAUI Blazor Hybrid. Starting getting this error after pushing my app to the App Store. Apparently the testers set it off nearly a hundred times in 10 minutes.

System.ExecutionEngineException: Attempting to JIT compile method '(wrapper delegate-invoke) void <Module>:invoke_callvirt_void_BindableT`1<string>_string (TallyIO.Client.Components.Inputs.Shared.BindableT`1<string>,string)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.

  ?, in void PropertySetter.CallPropertySetter<BindableT<string>, string>(Action<BindableT<string>, string> setter, object target, object value)
  ?, in void PropertySetter.SetValue(object, object)
  ?, in void ComponentProperties.SetProperties(in ParameterView, object)+SetProperty(object, PropertySetter, string, object)
System.InvalidOperationException: Unable to set property 'ThisRef' on object of type 'TallyIO.Client.Components.Inputs.Shared.BindableT`1[[System.String, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]'.
The error was: Attempting to JIT compile method '(wrapper delegate-invoke) void <Module>:invoke_callvirt_void_BindableT`1<string>_string (TallyIO.Client.Components.Inputs.Shared.BindableT`1<string>,string)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.

  ?, in void ComponentProperties.SetProperties(in ParameterView, object)+SetProperty(object, PropertySetter, string, object)
  ?, in void ComponentProperties.SetProperties(in ParameterView, object)
  ?, in Task ComponentBase.SetParametersAsync(ParameterView parameters)
  ?, in async Task TallyComponent.SetParametersAsync(ParameterView parameters)
  ?, in void IpcSender.NotifyUnhandledException(Exception exception)+() => { } [1]
  ?, in Task<T> DispatcherExtensions.DispatchAsync<T>(IDispatcher dispatcher, Func<T> func)+() => { } x 2

Steps to Reproduce

Run New MAUI Hybrid app in release, set properties on a component that uses Generics for implementation.

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, macOS

Affected platform versions

iOS 15.5 is what I’ve seen so far.

Did you find any workaround?

No

Relevant log output

No response

@MackinnonBuck
Copy link
Member

@lewing Do you know what might be going on here?

@Kylar182
Copy link
Author

@lewing Do you know what might be going on here?

EF Core SQLite

I believe these are related. Assuming the compiler is acting differently in Release than it is Debug

@MackinnonBuck MackinnonBuck transferred this issue from dotnet/maui Aug 16, 2022
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Aug 16, 2022
@ghost
Copy link

ghost commented Aug 16, 2022

Tagging subscribers to this area: @dotnet/area-system-componentmodel
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

having a Release only issue with Components on MAUI Blazor Hybrid. Starting getting this error after pushing my app to the App Store. Apparently the testers set it off nearly a hundred times in 10 minutes.

System.ExecutionEngineException: Attempting to JIT compile method '(wrapper delegate-invoke) void :invoke_callvirt_void_BindableT1<string>_string (TallyIO.Client.Components.Inputs.Shared.BindableT1,string)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.

?, in void PropertySetter.CallPropertySetter<BindableT, string>(Action<BindableT, string> setter, object target, object value)
?, in void PropertySetter.SetValue(object, object)
?, in void ComponentProperties.SetProperties(in ParameterView, object)+SetProperty(object, PropertySetter, string, object)
System.InvalidOperationException: Unable to set property 'ThisRef' on object of type 'TallyIO.Client.Components.Inputs.Shared.BindableT1[[System.String, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]'. The error was: Attempting to JIT compile method '(wrapper delegate-invoke) void <Module>:invoke_callvirt_void_BindableT1_string (TallyIO.Client.Components.Inputs.Shared.BindableT`1,string)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.

?, in void ComponentProperties.SetProperties(in ParameterView, object)+SetProperty(object, PropertySetter, string, object)
?, in void ComponentProperties.SetProperties(in ParameterView, object)
?, in Task ComponentBase.SetParametersAsync(ParameterView parameters)
?, in async Task TallyComponent.SetParametersAsync(ParameterView parameters)
?, in void IpcSender.NotifyUnhandledException(Exception exception)+() => { } [1]
?, in Task DispatcherExtensions.DispatchAsync(IDispatcher dispatcher, Func func)+() => { } x 2

Steps to Reproduce

Run New MAUI Hybrid app in release, set properties on a component that uses Generics for implementation.

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, macOS

Affected platform versions

iOS 15.5 is what I’ve seen so far.

Did you find any workaround?

No

Relevant log output

No response

Author: Kylar182
Assignees: -
Labels:

area-System.ComponentModel, t/bug, area/blazor 🕸️

Milestone: -

@MackinnonBuck
Copy link
Member

Moving to runtime because this problem appears to be specific to AOT.

@ericstj
Copy link
Member

ericstj commented Aug 16, 2022

I believe the problem here is that ASP.NET is creating generic delegates here which requires JIT.
https://github.com/dotnet/aspnetcore/blob/c85baf8db0c72ae8e68643029d514b2e737c9fae/src/Components/Components/src/Reflection/PropertySetter.cs#L31-L36

@agocke is there something that ASP.NET Or the application can do to tell the AOT tooling to pre-generate this delegate?

@MichalStrehovsky
Copy link
Member

@agocke is there something that ASP.NET Or the application can do to tell the AOT tooling to pre-generate this delegate?

This is Mono AOT. Re-pathed to there.

@SamMonoRT
Copy link
Member

@radical @vargaz - please can you take a look.

@SamMonoRT
Copy link
Member

""Attempting to JIT compile method METHOD NAME while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.""

I think we addressed a similar issue before ?

@SamMonoRT
Copy link
Member

cc @rolfbjarne fyi

@rolfbjarne
Copy link
Member

@SamMonoRT there are numerous other open issues due to the same exception, but each case usually needs investigation to figure out the underlying cause (they're not all the same).

FWIW maybe it would help if the AOT compiler emitted a warning when it can't AOT compile a method, explaining why? And in that case we could just ask for a build log, and match the stack trace to a method in a warning.

@tinytownsoftware
Copy link

Just chiming in here. I am getting the same error when using Telerik's Blazor libraries in a Blazor Hybrid application. Everything works on simulators (and my new app is already in the Google Play Store), except on a real iOS device. I would be more than happy to give more details if required. I've contacted Telerik about this, but I doubt they can do anything as this seems to be a MAUI issue.

@tinytownsoftware
Copy link

After many tears, I found that this fixed my issue:

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

I also added a bunch of --linkskip arguments to MtouchExtraArgs for things like the Telerik library, my Razor library the MAUI app shares with Blazor Server app, as well as AutoMapper for good measure. Not sure if these did anything, but I ain't changing nothing now that I got it working.

@Kylar182
Copy link
Author

After many tears, I found that this fixed my issue:


<PropertyGroup>

    <UseInterpreter>true</UseInterpreter>

</PropertyGroup>

I also added a bunch of --linkskip arguments to MtouchExtraArgs for things like the Telerik library, my Razor library the MAUI app shares with Blazor Server app, as well as AutoMapper for good measure. Not sure if these did anything, but I ain't changing nothing now that I got it working.

Use Interpreter did nothing for me. What're the Linkship and MtoichExtraArgs things you did?

@naricc
Copy link
Contributor

naricc commented Aug 22, 2022

@Kylar182 I am trying to reproduce this issue and find out what the AOT compiler is doing. Can you give me a minimal repro?

Like, of I start with dotnet new maui (or do I need to start with something else?), do you know the minimum program I can make from there to reproduce this?

@lambdageek
Copy link
Member

@Kylar182 I am trying to reproduce this issue and find out what the AOT compiler is doing. Can you give me a minimal repro?

Like, of I start with dotnet new maui (or do I need to start with something else?), do you know the minimum program I can make from there to reproduce this?

@naricc

dotnet new maui-blazor

From the stack trace it looks like you then need to make a razor page that has some components on them that will have the ComponentBase.SetParametersAsync called.
https://github.com/dotnet/aspnetcore/blob/d3401f5c8b5661d3163c80ff8a9ab5cec67b7a52/src/Components/Components/src/ComponentBase.cs#L208-L210

That function evidently uses reflection to set component parameter properties, which will then fail since we can't AOT those kind of reflection-heavy code

https://github.com/dotnet/aspnetcore/blob/d3401f5c8b5661d3163c80ff8a9ab5cec67b7a52/src/Components/Components/src/Reflection/PropertySetter.cs#L35-L41

I don't know enough about Razor to say how to make a page & components that will have SetParametersAsync called on them. but it should be possible to make a relatively concise repro. this is fundamentally not AOT-friendly code

@tinytownsoftware
Copy link

@Kylar182 I did a linkskip on both my own Razor library and the UI library I was using, in this case Telerik.

@naricc
Copy link
Contributor

naricc commented Aug 24, 2022

@SteveSandersonMS Might you know how I can construct a program with Component that has SetParametersAsync called on it? I'm not that familiar with this stuff.

@naricc naricc removed the untriaged New issue has not been triaged by the area owner label Aug 24, 2022
@naricc naricc added this to the 8.0.0 milestone Aug 24, 2022
@RenatoCaenaro
Copy link

@naricc in this issue (already related) you can find a minimal repo to try:
dotnet/maui#9176

@Kylar182
Copy link
Author

Kylar182 commented Sep 2, 2022

@Kylar182 I am trying to reproduce this issue and find out what the AOT compiler is doing. Can you give me a minimal repro?

Like, of I start with dotnet new maui (or do I need to start with something else?), do you know the minimum program I can make from there to reproduce this?

I'm in the middle of some timely feature deliveries on a couple other applications but I'll be able too in a couple weeks. I think on issue with that is that you'll need your own iOS deployment set up for pushing to Test Flight.

@Kylar182
Copy link
Author

Kylar182 commented Sep 2, 2022

@Kylar182 I am trying to reproduce this issue and find out what the AOT compiler is doing. Can you give me a minimal repro?

Like, of I start with dotnet new maui (or do I need to start with something else?), do you know the minimum program I can make from there to reproduce this?

I believe this is likely a related issue because using his work around worked for me as well. On the App Store now.

@SamMonoRT
Copy link
Member

@LeVladIonescu - this is similar to other issue in your queue. Please take a look.

@SamMonoRT SamMonoRT modified the milestones: 8.0.0, 9.0.0 Aug 3, 2023
@SamMonoRT
Copy link
Member

@vargaz - moved this to 9.0.0, but any suggestions here?

@vargaz
Copy link
Contributor

vargaz commented Aug 3, 2023

I think this is a dup of:
#78889
and similar bugs, and its supposed to be fixed in 8.0.

@LeVladIonescu
Copy link
Contributor

This should be fixed by #85643.

@LeVladIonescu
Copy link
Contributor

@Kylar182 please re-open it if you still encounter the issue with .NET8.

@ghost ghost locked as resolved and limited conversation to collaborators Nov 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests