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

[Bug] Json serializer fails on iOS in release mode (AOT) - regression in v4.52.0 #4082

Closed
1 of 7 tasks
espenrl opened this issue Apr 14, 2023 · 5 comments · Fixed by #4096
Closed
1 of 7 tasks

[Bug] Json serializer fails on iOS in release mode (AOT) - regression in v4.52.0 #4082

espenrl opened this issue Apr 14, 2023 · 5 comments · Fixed by #4096
Assignees
Labels
bug P1 regression Behavior that worked in a previous release that no longer works in a newer release scenario:Mobile-iOS
Milestone

Comments

@espenrl
Copy link

espenrl commented Apr 14, 2023

Stack trace

System.ExecutionEngineException: Attempting to JIT compile method '(wrapper delegate-invoke) void <Module>:invoke_callvirt_void_Dictionary`2<string, JToken>_string_JToken (System.Collections.Generic.Dictionary`2<string, Microsoft.Identity.Json.Linq.JToken>,string,Microsoft.Identity.Json.Linq.JToken)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.

  ?, in int ActionCallInstruction<Dictionary<string, JToken>, string, JToken>.Run(InterpretedFrame)
  ?, in void Interpreter.Run(InterpretedFrame)
  ?, in object LightLambda.Run(params object[])
  ?, in object DelegateHelpers.FuncThunk2<object, object[], object>(Func<object[], object> handler, object t1, object[] t2)
  ?, in void <>c__DisplayClass45_1.<SetExtensionDataDelegates>b__0(?)+(object o, string key, object value) => { }
  ?, in void JsonSerializerInternalReader.SetExtensionData(JsonObjectContract contract, JsonProperty member, JsonReader reader, string memberName, object o)
Microsoft.Identity.Json.JsonSerializationException: Error setting value in extension data for type 'Microsoft.Identity.Client.OAuth2.MsalTokenResponse'. Path 'not_before', line 1, position 3126.
  ?, in void JsonSerializerInternalReader.SetExtensionData(JsonObjectContract contract, JsonProperty member, JsonReader reader, string memberName, object o)
  ?, in object JsonSerializerInternalReader.PopulateObject(object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, string id)
  ?, in object JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, object existingValue)
  ?, in object JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, object existingValue)
  ?, in object JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, bool checkAdditionalContent)
  ?, in object JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
  ?, in object JsonConvert.DeserializeObject(string value, Type type, JsonSerializerSettings settings)
  ?, in MsalTokenResponse JsonConvert.DeserializeObject<MsalTokenResponse>(string value, JsonSerializerSettings settings)
  ?, in MsalTokenResponse JsonHelper.DeserializeFromJson<MsalTokenResponse>(string json)
  ?, in MsalTokenResponse OAuth2Client.CreateResponse<MsalTokenResponse>(HttpResponse response, RequestContext requestContext)
  ?, in async void <ExecuteRequestAsync>d__12<MsalTokenResponse>.MoveNext()
  ?, in async Task<MsalTokenResponse> OAuth2Client.GetTokenAsync(Uri endPoint, RequestContext requestContext, bool addCommonHeaders, Func<OnBeforeTokenRequestData, Task> onBeforePostRequestHandler)
  ?, in async Task<MsalTokenResponse> TokenClient.SendHttpAndClearTelemetryAsync(string tokenEndpoint, ILoggerAdapter logger)
  ?, in async Task<MsalTokenResponse> TokenClient.SendTokenRequestAsync(IDictionary<string, string> additionalBodyParameters, string scopeOverride, string tokenEndpointOverride, CancellationToken cancellationToken)
  ?, in async Task<MsalTokenResponse> InteractiveRequest.GetTokenResponseAsync(CancellationToken cancellationToken)
  ?, in async Task<AuthenticationResult> InteractiveRequest.ExecuteAsync(CancellationToken cancellationToken)
  ?, in async Task<AuthenticationResult> RequestBase.RunAsync(CancellationToken cancellationToken)
  ?, in async Task<AuthenticationResult> PublicClientExecutor.ExecuteAsync(AcquireTokenCommonParameters commonParameters, AcquireTokenInteractiveParameters interactiveParameters, CancellationToken cancellationToken)

Which version of MSAL.NET are you using?

Microsoft.Identity.Client 4.52.0
Microsoft.Identity.Client.Extensions.Msal 2.28.0

Platform

MAUI v7.0.59

What authentication flow has the issue?

  • Desktop / Mobile
    • Interactive
    • Integrated Windows Authentication
    • Username Password
    • Device code flow (browserless)
  • Web app
    • Authorization code
    • On-Behalf-Of
  • Daemon app
    • Service to Service calls

Is this a new or existing app?

The app is in production, and I have upgraded to a new version of MSAL.

Possible solution

Fallback to v4.51.0 / v2.27.0

@bgavrilMS
Copy link
Member

@espenrl - does it work with an older version of MSAL?

@espenrl
Copy link
Author

espenrl commented Apr 14, 2023

Yes, it is a regression in 4.52.0. It works in 4.51.0

@bgavrilMS bgavrilMS added the regression Behavior that worked in a previous release that no longer works in a newer release label Apr 14, 2023
@bgavrilMS
Copy link
Member

This must be due to 218643b

I think we may have to move to System.Text.Json or disable the functionality on iOS.

@espenrl
Copy link
Author

espenrl commented Apr 14, 2023

I am not familiar with the code, perhaps it could be made compatible with AOT.

@espenrl
Copy link
Author

espenrl commented Apr 21, 2023

I think the main problem is return System.Collections.Immutable.ImmutableDictionary<TKey, TValue>.Empty; In my experience AOT doesn't work well with immutable collections and JSON serialization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug P1 regression Behavior that worked in a previous release that no longer works in a newer release scenario:Mobile-iOS
Projects
Archived in project
2 participants