dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.2k stars 1.75k forks source link

Generics Serialization using Json.NET throws "Attempting to JIT compile method '(wrapper delegate-invoke)' while running in aot-only mode" in signed release build iOS-applications #8122

Closed nvdovkin closed 1 year ago

nvdovkin commented 2 years ago

Description

It seems like signed release build ios applications have some problems serializing and deserializing generics using Newtonsoft.Json library. When you try to serialize or deserialize an object inherited by a baseclass which implements an interface of a generic type, you get an exception, that the properties, which are defined in the the interface could not be set or get during serialization or deserialization. According to the stack trace, the app crashes with the additional error "Attempting to JIT compile method '(wrapper delegate-invoke)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information. (System.ExecutionEngineException)".

This error only occurs on release builds in signed ios applications on physical devices and with Newtonsoft.Json library. Using System.Text.Json the serialization and deserialization of objects behaves as expected.

I ran the iOS application on an M1 Macbook and received the crash log which I will attach in the section below

Sample demo: Deserializable_Demo.zip

The issue in the attached demo is caused by implementing "IDeserializable where T : IDeserializable, new ()" Deserializable.cs

Steps to Reproduce

1.) Run the attached demo on ios-simulator and serialize/deserialize the DeserializableBase object by clicking the "Serialize/Deserialize me" Button in MainPage.xaml.cs. You can notice, that both serializers behaves as expected. Both labels "System.Text.Json" and "Newtonsoft.Json" indicates the status "Ok". The application does not crash. 2.) build the attached demo in release mode, sign it with your provisioning profile and run it on a physical device. Try to serialize/deserialize the DeserializableBase object by clicking the "Serialize/Deserialize me" Button. You can now notice, that the application crashes and produces the error described previously

Version with bug

6.0.400 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, I was not able test on other platforms

Affected platform versions

iOS 15.4.1

Did you find any workaround?

I'm not aware of any workaround other than replacing Newtonsoft.Json library entirely with System.Json.Text.

Relevant log output

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Incident Identifier: 610F3AD2-190F-48A2-B256-0371F2915A55
CrashReporter Key:   5BFE5BBC-E777-F7E7-9199-6ADE0B2F2528
Hardware Model:      MacBookAir10,1
Process:             DeserializablePoC [70547]
Path:                /private/var/folders/*/DeserializablePoC.app/DeserializablePoC
Identifier:          com.expectare.p2058
Version:             1.0 (1)
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.expectare.p2058 [1111]

Date/Time:           2022-06-16 16:49:42.9110 +0200
Launch Time:         2022-06-16 16:49:36.6709 +0200
OS Version:          macOS 12.1 (21C52)
Release Type:        User
Report Version:      104

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x0000000188e821c8
Exception Note:  EXC_CORPSE_NOTIFY
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [70547]

Triggered by Thread:  0

Application Specific Information:
Crashing on exception: Error getting value from 'Id' on 'Models.Deserializable.DeserializableBase'. (Newtonsoft.Json.JsonSerializationException)
at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)
at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, JsonSerializerSettings settings)
at DeserializablePoC.MainPage.OnCounterClicked(Object sender, EventArgs e)
at Microsoft.Maui.Controls.Button.Microsoft.Maui.Controls.Internals.IButtonElement.PropagateUpClicked()
at Microsoft.Maui.Controls.ButtonElement.ElementClicked(VisualElement visualElement, IButtonElement ButtonElementManager)
at Microsoft.Maui.Controls.Button.SendClicked()
at Microsoft.Maui.Controls.Button.Microsoft.Maui.IButton.Clicked()
at Microsoft.Maui.Handlers.ButtonHandler.OnButtonTouchUpInside(Object sender, EventArgs e)
at UIKit.UIControlEventProxy.Activated()
Attempting to JIT compile method '(wrapper delegate-invoke) string <Module>:invoke_callvirt_string_Deserializable`1<DeserializableBase> (Models.Deserializable.Deserializable`1<Models.Deserializable.DeserializableBase>)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.
(System.ExecutionEngineException)
at System.Linq.Expressions.Interpreter.FuncCallInstruction`2[[Models.Deserializable.Deserializable`1[[Models.Deserializable.DeserializableBase, DeserializablePoC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], DeserializablePoC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.String, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Run(InterpretedFrame )
at System.Linq.Expressions.Interpreter.Interpreter.Run(InterpretedFrame )
at System.Linq.Expressions.Interpreter.LightLambda.Run(Object[] )
at System.Dynamic.Utils.DelegateHelpers.FuncThunk1[Object,Object](Func`2 handler, Object t1)
at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)

Thread 0 Crashed:: tid_103 Dispatch queue: com.apple.main-thread
0   AppKit                                 0x188e821c8 -[NSApplication _crashOnException:] + 324
1   AppKit                                 0x188e821c0 -[NSApplication _crashOnException:] + 316
2   AppKit                                 0x188e81ee0 -[NSApplication reportException:] + 588
3   AppKit                                 0x188af5668 -[NSApplication run] + 792
4   AppKit                                 0x188ac6c78 NSApplicationMain + 1064
5   AppKit                                 0x188d9d084 _NSApplicationMainWithInfoDictionary + 24
6   UIKitMacHelper                         0x19b4ad9ac UINSApplicationMain + 1280
7   UIKitCore                              0x1ad43ab28 UIApplicationMain + 164
8   DeserializablePoC                      0x102fa342c wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 396 (/<unknown>:1)
9   DeserializablePoC                      0x104f74ee0 Microsoft_iOS_UIKit_UIApplication_Main_string___System_Type_System_Type + 264
10  DeserializablePoC                      0x1052f0ef0 mono_jit_runtime_invoke + 1308 (mini-runtime.c:3460)
11  DeserializablePoC                      0x10523c698 do_runtime_invoke + 60 (object.c:2396) [inlined]
12  DeserializablePoC                      0x10523c698 mono_runtime_invoke_checked + 148 (object.c:2564)
13  DeserializablePoC                      0x1052420b0 do_exec_main_checked + 60 [inlined]
14  DeserializablePoC                      0x1052420b0 mono_runtime_exec_main_checked + 116 (object.c:4506)
15  DeserializablePoC                      0x1052f5b0c mono_jit_exec_internal + 16 (driver.c:1381) [inlined]
16  DeserializablePoC                      0x1052f5b0c mono_jit_exec + 356 (driver.c:1326)
17  DeserializablePoC                      0x10509aca8 xamarin_main + 972 (monotouch-main.m:494)
18  DeserializablePoC                      0x10535fc9c main + 64 (main.arm64.mm:201)
19  dyld                                   0x105aad0f4 start + 520

Thread 1:
0   libsystem_pthread.dylib                0x185ee0010 start_wqthread + 0

Thread 2:
0   libsystem_pthread.dylib                0x185ee0010 start_wqthread + 0

Thread 3:: SGen worker
0   libsystem_kernel.dylib                 0x185ead0c0 __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x185ee5808 _pthread_cond_wait + 1228
2   DeserializablePoC                      0x1052e23e0 mono_os_cond_wait + 8 (mono-os-mutex.h:219) [inlined]
3   DeserializablePoC                      0x1052e23e0 get_work + 8 (sgen-thread-pool.c:167) [inlined]
4   DeserializablePoC                      0x1052e23e0 thread_func + 244 (sgen-thread-pool.c:198)
5   libsystem_pthread.dylib                0x185ee5240 _pthread_start + 148
6   libsystem_pthread.dylib                0x185ee0024 thread_start + 8

Thread 4:: Finalizer
0   libsystem_kernel.dylib                 0x185ea9990 semaphore_wait_trap + 8
1   DeserializablePoC                      0x105271ea0 mono_os_sem_wait + 12 (mono-os-semaphore.h:85) [inlined]
2   DeserializablePoC                      0x105271ea0 mono_coop_sem_wait + 32 (mono-coop-semaphore.h:41) [inlined]
3   DeserializablePoC                      0x105271ea0 finalizer_thread + 320 (gc.c:876)
4   DeserializablePoC                      0x105250658 start_wrapper_internal + 328 (threads.c:1201)
5   DeserializablePoC                      0x1052504f8 start_wrapper + 68 (threads.c:1263)
6   libsystem_pthread.dylib                0x185ee5240 _pthread_start + 148
7   libsystem_pthread.dylib                0x185ee0024 thread_start + 8

Thread 5:
0   libsystem_pthread.dylib                0x185ee0010 start_wqthread + 0

Thread 6:
0   libsystem_pthread.dylib                0x185ee0010 start_wqthread + 0

Thread 7:: com.apple.uikit.eventfetch-thread
0   libsystem_kernel.dylib                 0x185ea9954 mach_msg_trap + 8
1   libsystem_kernel.dylib                 0x185ea9d00 mach_msg + 76
2   CoreFoundation                         0x185fb0ed8 __CFRunLoopServiceMachPort + 372
3   CoreFoundation                         0x185faf390 __CFRunLoopRun + 1212
4   CoreFoundation                         0x185fae734 CFRunLoopRunSpecific + 600
5   Foundation                             0x186e83da0 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 236
6   Foundation                             0x186f0e4e4 -[NSRunLoop(NSRunLoop) runUntilDate:] + 124
7   UIKitCore                              0x1ad43c2a0 -[UIEventFetcher threadMain] + 156
8   Foundation                             0x186e7c2e8 __NSThread__start__ + 808
9   libsystem_pthread.dylib                0x185ee5240 _pthread_start + 148
10  libsystem_pthread.dylib                0x185ee0024 thread_start + 8

Thread 8:
0   libsystem_pthread.dylib                0x185ee0010 start_wqthread + 0

Thread 9:: com.apple.NSEventThread
0   libsystem_kernel.dylib                 0x185ea9954 mach_msg_trap + 8
1   libsystem_kernel.dylib                 0x185ea9d00 mach_msg + 76
2   CoreFoundation                         0x185fb0ed8 __CFRunLoopServiceMachPort + 372
3   CoreFoundation                         0x185faf390 __CFRunLoopRun + 1212
4   CoreFoundation                         0x185fae734 CFRunLoopRunSpecific + 600
5   AppKit                                 0x188c71c90 _NSEventThread + 196
6   libsystem_pthread.dylib                0x185ee5240 _pthread_start + 148
7   libsystem_pthread.dylib                0x185ee0024 thread_start + 8

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x00000001212b5800   x1: 0x000000016d3d2400   x2: 0x0000000000000004   x3: 0x00000001212b6800
    x4: 0x00000000000000c7   x5: 0x000000016d3d2348   x6: 0x0000000000000005   x7: 0x000000018619b89c
    x8: 0x00000001dc370000   x9: 0x85dd92d3846400c5  x10: 0x0000000000000001  x11: 0x00000001212b68c7
   x12: 0x00000000fca02400  x13: 0x0000000000000002  x14: 0x000000000000fffd  x15: 0x0000000000000003
   x16: 0x0000000000000001  x17: 0x000000016d3d258e  x18: 0x0000000128853940  x19: 0x00000001261a9b30
   x20: 0x00000001d041553c  x21: 0x0000000120640f00  x22: 0x00000001d0410000  x23: 0x00000001def76000
   x24: 0x00000001dc35a000  x25: 0x00000001261a9b30  x26: 0x00000001207b8710  x27: 0x00000001261a9be0
   x28: 0x0000000000000001   fp: 0x000000016d3d2e00   lr: 0x5058000188e821c0
    sp: 0x000000016d3d2db0   pc: 0x0000000188e821c8 cpsr: 0x60001000
   far: 0x00000001212b8600  esr: 0xf2000001 (Breakpoint) brk 1

Binary Images:
       0x188ac3000 -        0x189976fff com.apple.AppKit (6.9) <a8bbc643-113d-310f-96b6-77a973bf2dba> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
       0x19b4a9000 -        0x19b5abfff com.apple.UIKitMacHelper (1.0) <efa91247-7c04-359b-80a4-341eb0bc511a> /System/Library/PrivateFrameworks/UIKitMacHelper.framework/Versions/A/UIKitMacHelper
       0x1ad437000 -        0x1aeb32fff com.apple.UIKitCore (1.0) <20a507f1-22b9-3e14-9573-7f2ab65b57b0> /System/iOSSupport/System/Library/PrivateFrameworks/UIKitCore.framework/Versions/A/UIKitCore
       0x102a2c000 -        0x105567fff com.expectare.p2058 (1.0) <b266dad8-0f57-3e82-8dcc-5e4e31d514c0> /private/var/folders/*/DeserializablePoC.app/DeserializablePoC
       0x105aa8000 -        0x105b07fff dyld (*) <7e92b284-4b90-3b68-b31a-3ddc4c0e8d40> /usr/lib/dyld
       0x185ede000 -        0x185eeafff libsystem_pthread.dylib (*) <ed328b18-eeef-3b15-8858-798b19b0c2cd> /usr/lib/system/libsystem_pthread.dylib
       0x185ea8000 -        0x185eddfff libsystem_kernel.dylib (*) <c8b3081a-5081-3a99-bbe3-01413de444c6> /usr/lib/system/libsystem_kernel.dylib
       0x185f2c000 -        0x18646ffff com.apple.CoreFoundation (6.9) <f5ea9592-4ef9-3d35-b23d-5c21283acc52> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
       0x186e20000 -        0x18720dfff com.apple.Foundation (6.9) <cd7cdf11-986e-3754-8011-e628c3be8380> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation

EOF

-----------
Full Report
-----------

{"app_name":"DeserializablePoC","timestamp":"2022-06-16 16:49:47.00 +0200","app_version":"1.0","slice_uuid":"b266dad8-0f57-3e82-8dcc-5e4e31d514c0","build_version":"1","platform":2,"bundleID":"com.expectare.p2058","share_with_app_devs":0,"is_first_party":0,"bug_type":"309","os_version":"macOS 12.1 (21C52)","incident_id":"610F3AD2-190F-48A2-B256-0371F2915A55","name":"DeserializablePoC"}
{
  "uptime" : 74000,
  "procLaunch" : "2022-06-16 16:49:36.6709 +0200",
  "procRole" : "Foreground",
  "version" : 2,
  "userID" : 501,
  "deployVersion" : 210,
  "modelCode" : "MacBookAir10,1",
  "procStartAbsTime" : 1781921131396,
  "coalitionID" : 1111,
  "osVersion" : {
    "train" : "macOS 12.1",
    "build" : "21C52",
    "releaseType" : "User"
  },
  "captureTime" : "2022-06-16 16:49:42.9110 +0200",
  "incident" : "610F3AD2-190F-48A2-B256-0371F2915A55",
  "bug_type" : "309",
  "pid" : 70547,
  "procExitAbsTime" : 1782070693546,
  "translated" : false,
  "cpuType" : "ARM-64",
  "procName" : "DeserializablePoC",
  "procPath" : "\/private\/var\/folders\/*\/DeserializablePoC.app\/DeserializablePoC",
  "bundleInfo" : {"CFBundleShortVersionString":"1.0","CFBundleVersion":"1","CFBundleIdentifier":"com.expectare.p2058"},
  "storeInfo" : {"deviceIdentifierForVendor":"B8083413-CF33-5FB5-A5C2-833086CBA671","thirdParty":true},
  "parentProc" : "launchd",
  "parentPid" : 1,
  "coalitionName" : "com.expectare.p2058",
  "crashReporterKey" : "5BFE5BBC-E777-F7E7-9199-6ADE0B2F2528",
  "wakeTime" : 15399,
  "sleepWakeUUID" : "8D3FB705-6E29-49EF-A311-69ECC44F4122",
  "sip" : "enabled",
  "isCorpse" : 1,
  "exception" : {"codes":"0x0000000000000001, 0x0000000188e821c8","rawCodes":[1,6591881672],"type":"EXC_BREAKPOINT","signal":"SIGTRAP"},
  "termination" : {"flags":0,"code":5,"namespace":"SIGNAL","indicator":"Trace\/BPT trap: 5","byProc":"exc handler","byPid":70547},
  "asi" : {"AppKit":["Crashing on exception: Error getting value from 'Id' on 'Models.Deserializable.DeserializableBase'. (Newtonsoft.Json.JsonSerializationException)","at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)","at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)","at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)","at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)","at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)","at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)","at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)","at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, Type type, JsonSerializerSettings settings)","at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, JsonSerializerSettings settings)","at DeserializablePoC.MainPage.OnCounterClicked(Object sender, EventArgs e)","at Microsoft.Maui.Controls.Button.Microsoft.Maui.Controls.Internals.IButtonElement.PropagateUpClicked()","at Microsoft.Maui.Controls.ButtonElement.ElementClicked(VisualElement visualElement, IButtonElement ButtonElementManager)","at Microsoft.Maui.Controls.Button.SendClicked()","at Microsoft.Maui.Controls.Button.Microsoft.Maui.IButton.Clicked()","at Microsoft.Maui.Handlers.ButtonHandler.OnButtonTouchUpInside(Object sender, EventArgs e)","at UIKit.UIControlEventProxy.Activated()","Attempting to JIT compile method '(wrapper delegate-invoke) string <Module>:invoke_callvirt_string_Deserializable`1<DeserializableBase> (Models.Deserializable.Deserializable`1<Models.Deserializable.DeserializableBase>)' while running in aot-only mode. See https:\/\/docs.microsoft.com\/xamarin\/ios\/internals\/limitations for more information.","(System.ExecutionEngineException)","at System.Linq.Expressions.Interpreter.FuncCallInstruction`2[[Models.Deserializable.Deserializable`1[[Models.Deserializable.DeserializableBase, DeserializablePoC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], DeserializablePoC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.String, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Run(InterpretedFrame )","at System.Linq.Expressions.Interpreter.Interpreter.Run(InterpretedFrame )","at System.Linq.Expressions.Interpreter.LightLambda.Run(Object[] )","at System.Dynamic.Utils.DelegateHelpers.FuncThunk1[Object,Object](Func`2 handler, Object t1)","at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)"]},
  "asiBacktraces" : ["0   CoreFoundation                      0x00000001860301cc __exceptionPreprocess + 240\n1   libobjc.A.dylib                     0x0000000185d817b8 objc_exception_throw + 60\n2   DeserializablePoC                   0x00000001050925d8 xamarin_get_block_descriptor + 9824\n3   DeserializablePoC                   0x0000000105364420 _ZNK3icu6number23NumberFormatterSettingsINS0_24LocalizedNumberFormatterEE10toSkeletonER10UErrorCode + 2360848\n4   DeserializablePoC                   0x0000000105385274 _ZNK3icu6number23NumberFormatterSettingsINS0_24LocalizedNumberFormatterEE10toSkeletonER10UErrorCode + 2495588\n5   UIKitCore                           0x00000001ad6f286c -[UIApplication sendAction:to:from:forEvent:] + 100\n6   UIKitCore                           0x00000001ad6fadf0 -[UIControl sendAction:to:forEvent:] + 128\n7   UIKitCore                           0x00000001ad6f92ac -[UIControl _sendActionsForEvents:withEvent:] + 360\n8   UIKitCore                           0x00000001adb48d50 -[UIButton _sendActionsForEvents:withEvent:] + 160\n9   UIKitCore                           0x00000001ad6fa904 -[UIControl touchesEnded:withEvent:] + 536\n10  UIKitCore                           0x00000001ad6daa3c -[UIWindow _sendTouchesForEvent:] + 1016\n11  UIKitCore                           0x00000001ad6bb4b8 -[UIWindow sendEvent:] + 4416\n12  UIKitCore                           0x00000001ad6b9854 -[UIApplication sendEvent:] + 848\n13  UIKitCore                           0x00000001ad6b7734 __dispatchPreprocessedEventFromEventQueue + 8000\n14  UIKitCore                           0x00000001ae1dedf4 __processEventQueue + 6816\n15  UIKitCore                           0x00000001ae1d9434 __eventFetcherSourceCallback + 208\n16  CoreFoundation                      0x0000000185fb0c5c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28\n17  CoreFoundation                      0x0000000185fb0ba8 __CFRunLoopDoSource0 + 208\n18  CoreFoundation                      0x0000000185fb0894 __CFRunLoopDoSources0 + 268\n19  CoreFoundation                      0x0000000185faf208 __CFRunLoopRun + 820\n20  CoreFoundation                      0x0000000185fae734 CFRunLoopRunSpecific + 600\n21  HIToolbox                           0x000000018eb40f68 RunCurrentEventLoopInMode + 292\n22  HIToolbox                           0x000000018eb40bf4 ReceiveNextEventCommon + 320\n23  HIToolbox                           0x000000018eb40a9c _BlockUntilNextEventMatchingListInModeWithFilter + 72\n24  AppKit                              0x0000000188b04ce0 _DPSNextEvent + 844\n25  AppKit                              0x0000000188b03584 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1332\n26  AppKit                              0x0000000188af55a4 -[NSApplication run] + 596\n27  AppKit                              0x0000000188ac6c78 NSApplicationMain + 1064\n28  AppKit                              0x0000000188d9d084 +[NSWindow _savedFrameFromString:] + 0\n29  UIKitMacHelper                      0x000000019b4ad9ac UINSApplicationMain + 1280\n30  UIKitCore                           0x00000001ad43ab28 UIApplicationMain + 164\n31  DeserializablePoC                   0x0000000102fa342c DeserializablePoC + 5731372\n32  DeserializablePoC                   0x0000000104f74ee0 DeserializablePoC + 39096032\n33  DeserializablePoC                   0x00000001052f0ef0 _ZNK3icu6number23NumberFormatterSettingsINS0_24LocalizedNumberFormatterEE10toSkeletonER10UErrorCode + 1888480\n34  DeserializablePoC                   0x000000010523c698 _ZNK3icu6number23NumberFormatterSettingsINS0_24LocalizedNumberFormatterEE10toSkeletonER10UErrorCode + 1149064\n35  DeserializablePoC                   0x00000001052420b0 _ZNK3icu6number23NumberFormatterSettingsINS0_24LocalizedNumberFormatterEE10toSkeletonER10UErrorCode + 1172128\n36  DeserializablePoC                   0x00000001052f5b0c _ZNK3icu6number23NumberFormatterSettingsINS0_24LocalizedNumberFormatterEE10toSkeletonER10UErrorCode + 1907964\n37  DeserializablePoC                   0x000000010509aca8 xamarin_log + 5064\n38  DeserializablePoC                   0x000000010535fc9c _ZNK3icu6number23NumberFormatterSettingsINS0_24LocalizedNumberFormatterEE10toSkeletonER10UErrorCode + 2342540\n39  dyld                                0x0000000105aad0f4 start + 520"],
  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
  "faultingThread" : 0,
  "threads" : [{"triggered":true,"id":753272,"threadState":{"x":[{"value":4851456000},{"value":6127690752},{"value":4},{"value":4851460096},{"value":199},{"value":6127690568},{"value":5},{"value":6544799900,"symbolLocation":0,"symbol":"firstByteMark"},{"value":7989559296,"symbolLocation":56,"symbol":"_OBJC_PROTOCOL_$_NSTextInputClient_Async"},{"value":9646027414054371525},{"value":1},{"value":4851460295},{"value":4238353408},{"value":2},{"value":65533},{"value":3},{"value":1},{"value":6127691150},{"value":4974786880},{"value":4934245168},{"value":7788909884,"objc-selector":"callStackSymbols"},{"value":4838395648},{"value":7788888064,"objc-selector":"ion"},{"value":8035721216,"symbolLocation":16,"symbol":"OBJC_CLASS_$__NSTextViewRulerHelper"},{"value":7989469184},{"value":4934245168},{"value":4839933712},{"value":4934245344},{"value":1}],"flavor":"ARM_THREAD_STATE64","lr":{"value":5789377327576654272},"cpsr":{"value":1610616832},"fp":{"value":6127693312},"sp":{"value":6127693232},"esr":{"value":4060086273,"description":"(Breakpoint) brk 1"},"pc":{"value":6591881672,"matchesCrashFrame":1},"far":{"value":4851467776}},"name":"tid_103","queue":"com.apple.main-thread","frames":[{"imageOffset":3928520,"symbol":"-[NSApplication _crashOnException:]","symbolLocation":324,"imageIndex":0},{"imageOffset":3928512,"symbol":"-[NSApplication _crashOnException:]","symbolLocation":316,"imageIndex":0},{"imageOffset":3927776,"symbol":"-[NSApplication reportException:]","symbolLocation":588,"imageIndex":0},{"imageOffset":206440,"symbol":"-[NSApplication run]","symbolLocation":792,"imageIndex":0},{"imageOffset":15480,"symbol":"NSApplicationMain","symbolLocation":1064,"imageIndex":0},{"imageOffset":2990212,"symbol":"_NSApplicationMainWithInfoDictionary","symbolLocation":24,"imageIndex":0},{"imageOffset":18860,"symbol":"UINSApplicationMain","symbolLocation":1280,"imageIndex":1},{"imageOffset":15144,"symbol":"UIApplicationMain","symbolLocation":164,"imageIndex":2},{"imageOffset":5731372,"sourceLine":1,"sourceFile":"\/<unknown>","symbol":"wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr","imageIndex":3,"symbolLocation":396},{"imageOffset":39096032,"symbol":"Microsoft_iOS_UIKit_UIApplication_Main_string___System_Type_System_Type","symbolLocation":264,"imageIndex":3},{"imageOffset":42749680,"sourceLine":3460,"sourceFile":"mini-runtime.c","symbol":"mono_jit_runtime_invoke","imageIndex":3,"symbolLocation":1308},{"symbol":"do_runtime_invoke","inline":true,"imageIndex":3,"imageOffset":42010264,"symbolLocation":60,"sourceLine":2396,"sourceFile":"object.c"},{"imageOffset":42010264,"sourceLine":2564,"sourceFile":"object.c","symbol":"mono_runtime_invoke_checked","imageIndex":3,"symbolLocation":148},{"imageOffset":42033328,"sourceFile":"object.c","symbol":"do_exec_main_checked","imageIndex":3,"symbolLocation":60,"inline":true},{"imageOffset":42033328,"sourceLine":4506,"sourceFile":"object.c","symbol":"mono_runtime_exec_main_checked","imageIndex":3,"symbolLocation":116},{"symbol":"mono_jit_exec_internal","inline":true,"imageIndex":3,"imageOffset":42769164,"symbolLocation":16,"sourceLine":1381,"sourceFile":"driver.c"},{"imageOffset":42769164,"sourceLine":1326,"sourceFile":"driver.c","symbol":"mono_jit_exec","imageIndex":3,"symbolLocation":356},{"imageOffset":40299688,"sourceLine":494,"sourceFile":"monotouch-main.m","symbol":"xamarin_main","imageIndex":3,"symbolLocation":972},{"imageOffset":43203740,"sourceLine":201,"sourceFile":"main.arm64.mm","symbol":"main","imageIndex":3,"symbolLocation":64},{"imageOffset":20724,"symbol":"start","symbolLocation":520,"imageIndex":4}]},{"id":753352,"frames":[{"imageOffset":8208,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}]},{"id":753353,"frames":[{"imageOffset":8208,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}]},{"id":753355,"name":"SGen worker","frames":[{"imageOffset":20672,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":6},{"imageOffset":30728,"symbol":"_pthread_cond_wait","symbolLocation":1228,"imageIndex":5},{"symbol":"mono_os_cond_wait","inline":true,"imageIndex":3,"imageOffset":42689504,"symbolLocation":8,"sourceLine":219,"sourceFile":"mono-os-mutex.h"},{"symbol":"get_work","inline":true,"imageIndex":3,"imageOffset":42689504,"symbolLocation":8,"sourceLine":167,"sourceFile":"sgen-thread-pool.c"},{"imageOffset":42689504,"sourceLine":198,"sourceFile":"sgen-thread-pool.c","symbol":"thread_func","imageIndex":3,"symbolLocation":244},{"imageOffset":29248,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":5},{"imageOffset":8228,"symbol":"thread_start","symbolLocation":8,"imageIndex":5}]},{"id":753356,"name":"Finalizer","frames":[{"imageOffset":6544,"symbol":"semaphore_wait_trap","symbolLocation":8,"imageIndex":6},{"symbol":"mono_os_sem_wait","inline":true,"imageIndex":3,"imageOffset":42229408,"symbolLocation":12,"sourceLine":85,"sourceFile":"mono-os-semaphore.h"},{"symbol":"mono_coop_sem_wait","inline":true,"imageIndex":3,"imageOffset":42229408,"symbolLocation":32,"sourceLine":41,"sourceFile":"mono-coop-semaphore.h"},{"imageOffset":42229408,"sourceLine":876,"sourceFile":"gc.c","symbol":"finalizer_thread","imageIndex":3,"symbolLocation":320},{"imageOffset":42092120,"sourceLine":1201,"sourceFile":"threads.c","symbol":"start_wrapper_internal","imageIndex":3,"symbolLocation":328},{"imageOffset":42091768,"sourceLine":1263,"sourceFile":"threads.c","symbol":"start_wrapper","imageIndex":3,"symbolLocation":68},{"imageOffset":29248,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":5},{"imageOffset":8228,"symbol":"thread_start","symbolLocation":8,"imageIndex":5}]},{"id":753363,"frames":[{"imageOffset":8208,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}]},{"id":753367,"frames":[{"imageOffset":8208,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}]},{"id":753368,"name":"com.apple.uikit.eventfetch-thread","frames":[{"imageOffset":6484,"symbol":"mach_msg_trap","symbolLocation":8,"imageIndex":6},{"imageOffset":7424,"symbol":"mach_msg","symbolLocation":76,"imageIndex":6},{"imageOffset":544472,"symbol":"__CFRunLoopServiceMachPort","symbolLocation":372,"imageIndex":7},{"imageOffset":537488,"symbol":"__CFRunLoopRun","symbolLocation":1212,"imageIndex":7},{"imageOffset":534324,"symbol":"CFRunLoopRunSpecific","symbolLocation":600,"imageIndex":7},{"imageOffset":408992,"symbol":"-[NSRunLoop(NSRunLoop) runMode:beforeDate:]","symbolLocation":236,"imageIndex":8},{"imageOffset":976100,"symbol":"-[NSRunLoop(NSRunLoop) runUntilDate:]","symbolLocation":124,"imageIndex":8},{"imageOffset":21152,"symbol":"-[UIEventFetcher threadMain]","symbolLocation":156,"imageIndex":2},{"imageOffset":377576,"symbol":"__NSThread__start__","symbolLocation":808,"imageIndex":8},{"imageOffset":29248,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":5},{"imageOffset":8228,"symbol":"thread_start","symbolLocation":8,"imageIndex":5}]},{"id":753369,"frames":[{"imageOffset":8208,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}]},{"id":753377,"name":"com.apple.NSEventThread","frames":[{"imageOffset":6484,"symbol":"mach_msg_trap","symbolLocation":8,"imageIndex":6},{"imageOffset":7424,"symbol":"mach_msg","symbolLocation":76,"imageIndex":6},{"imageOffset":544472,"symbol":"__CFRunLoopServiceMachPort","symbolLocation":372,"imageIndex":7},{"imageOffset":537488,"symbol":"__CFRunLoopRun","symbolLocation":1212,"imageIndex":7},{"imageOffset":534324,"symbol":"CFRunLoopRunSpecific","symbolLocation":600,"imageIndex":7},{"imageOffset":1764496,"symbol":"_NSEventThread","symbolLocation":196,"imageIndex":0},{"imageOffset":29248,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":5},{"imageOffset":8228,"symbol":"thread_start","symbolLocation":8,"imageIndex":5}]}],
  "usedImages" : [
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6587953152,
    "CFBundleShortVersionString" : "6.9",
    "CFBundleIdentifier" : "com.apple.AppKit",
    "size" : 15417344,
    "uuid" : "a8bbc643-113d-310f-96b6-77a973bf2dba",
    "path" : "\/System\/Library\/Frameworks\/AppKit.framework\/Versions\/C\/AppKit",
    "name" : "AppKit",
    "CFBundleVersion" : "2113.20.111"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6900322304,
    "CFBundleShortVersionString" : "1.0",
    "CFBundleIdentifier" : "com.apple.UIKitMacHelper",
    "size" : 1060864,
    "uuid" : "efa91247-7c04-359b-80a4-341eb0bc511a",
    "path" : "\/System\/Library\/PrivateFrameworks\/UIKitMacHelper.framework\/Versions\/A\/UIKitMacHelper",
    "name" : "UIKitMacHelper",
    "CFBundleVersion" : "5205.0.401"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 7201845248,
    "CFBundleShortVersionString" : "1.0",
    "CFBundleIdentifier" : "com.apple.UIKitCore",
    "size" : 24100864,
    "uuid" : "20a507f1-22b9-3e14-9573-7f2ab65b57b0",
    "path" : "\/System\/iOSSupport\/System\/Library\/PrivateFrameworks\/UIKitCore.framework\/Versions\/A\/UIKitCore",
    "name" : "UIKitCore",
    "CFBundleVersion" : "5205.0.401"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4339187712,
    "CFBundleShortVersionString" : "1.0",
    "CFBundleIdentifier" : "com.expectare.p2058",
    "size" : 45334528,
    "uuid" : "b266dad8-0f57-3e82-8dcc-5e4e31d514c0",
    "path" : "\/private\/var\/folders\/*\/DeserializablePoC.app\/DeserializablePoC",
    "name" : "DeserializablePoC",
    "CFBundleVersion" : "1"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 4390027264,
    "size" : 393216,
    "uuid" : "7e92b284-4b90-3b68-b31a-3ddc4c0e8d40",
    "path" : "\/usr\/lib\/dyld",
    "name" : "dyld"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6541926400,
    "size" : 53248,
    "uuid" : "ed328b18-eeef-3b15-8858-798b19b0c2cd",
    "path" : "\/usr\/lib\/system\/libsystem_pthread.dylib",
    "name" : "libsystem_pthread.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6541705216,
    "size" : 221184,
    "uuid" : "c8b3081a-5081-3a99-bbe3-01413de444c6",
    "path" : "\/usr\/lib\/system\/libsystem_kernel.dylib",
    "name" : "libsystem_kernel.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6542245888,
    "CFBundleShortVersionString" : "6.9",
    "CFBundleIdentifier" : "com.apple.CoreFoundation",
    "size" : 5521408,
    "uuid" : "f5ea9592-4ef9-3d35-b23d-5c21283acc52",
    "path" : "\/System\/Library\/Frameworks\/CoreFoundation.framework\/Versions\/A\/CoreFoundation",
    "name" : "CoreFoundation",
    "CFBundleVersion" : "1856.105"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6557925376,
    "CFBundleShortVersionString" : "6.9",
    "CFBundleIdentifier" : "com.apple.Foundation",
    "size" : 4120576,
    "uuid" : "cd7cdf11-986e-3754-8011-e628c3be8380",
    "path" : "\/System\/Library\/Frameworks\/Foundation.framework\/Versions\/C\/Foundation",
    "name" : "Foundation",
    "CFBundleVersion" : "1856.105"
  }
],
  "sharedCache" : {
  "base" : 6538756096,
  "size" : 3089596416,
  "uuid" : "66c33c62-48a9-31e5-b8b5-7a71c9760d07"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=1.1G resident=0K(0%) swapped_out_or_unallocated=1.1G(100%)\nWritable regions: Total=330.9M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=330.9M(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nAccelerate framework               384K        3 \nActivity Tracing                   256K        1 \nCG backing stores                 2176K        4 \nCG image                            48K        2 \nColorSync                          544K       26 \nCoreAnimation                      912K       25 \nCoreGraphics                        16K        1 \nCoreUI image data                  912K        6 \nDispatch continuations            64.0M        1 \nFoundation                          48K        2 \nImage IO                           560K        1 \nKernel Alloc Once                   32K        1 \nMALLOC                           116.3M       47 \nMALLOC guard page                  192K       10 \nMALLOC_MEDIUM (reserved)         112.0M        1         reserved VM address space (unallocated)\nSTACK GUARD                       56.2M       10 \nStack                             14.3M       10 \nVM_ALLOCATE                        1.0G       33 \n__AUTH                            3168K      385 \n__AUTH_CONST                      21.9M      589 \n__CTF                               759        1 \n__DATA                            15.8M      574 \n__DATA_CONST                      23.0M      596 \n__DATA_DIRTY                      2454K      269 \n__FONT_DATA                          4K        1 \n__LINKEDIT                       576.6M        4 \n__OBJC_CONST                      4786K      350 \n__OBJC_RO                         82.0M        1 \n__OBJC_RW                         3104K        1 \n__TEXT                           562.2M      613 \n__UNICODE                          588K        1 \ndyld private memory               1024K        1 \nmapped file                      165.2M      136 \nshared memory                      864K       14 \n===========                     =======  ======= \nTOTAL                              2.8G     3720 \nTOTAL, minus reserved VM space     2.7G     3720 \n",
  "legacyInfo" : {
  "threadTriggered" : {
    "name" : "tid_103",
    "queue" : "com.apple.main-thread"
  }
},
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "607844aa04477260f58a8077",
      "factorPackIds" : {
        "SIRI_MORPHUN_ASSETS" : "6103050cbfe6dc472e1c982a"
      },
      "deploymentId" : 240000066
    },
    {
      "rolloutId" : "60da5e84ab0ca017dace9abf",
      "factorPackIds" : {

      },
      "deploymentId" : 240000008
    },
    {
      "rolloutId" : "602ad4dac86151000cf27e46",
      "factorPackIds" : {
        "SIRI_DICTATION_ASSETS" : "61fb0e87c773c43cde3bb80e"
      },
      "deploymentId" : 240000305
    },
    {
      "rolloutId" : "601d9415f79519000ccd4b69",
      "factorPackIds" : {
        "SIRI_TEXT_TO_SPEECH" : "621d4d0f680160486b9e1c98"
      },
      "deploymentId" : 240000416
    },
    {
      "rolloutId" : "5fb4245a1bbfe8005e33a1e1",
      "factorPackIds" : {

      },
      "deploymentId" : 240000015
    },
    {
      "rolloutId" : "5fc94383418129005b4e9ae0",
      "factorPackIds" : {

      },
      "deploymentId" : 240000370
    },
    {
      "rolloutId" : "5ffde50ce2aacd000d47a95f",
      "factorPackIds" : {

      },
      "deploymentId" : 240000158
    }
  ],
  "experiments" : [

  ]
}
}

Model: MacBookAir10,1, BootROM 7429.61.2, proc 8:4:4 processors, 8 GB, SMC 
Graphics: Apple M1, Apple M1, Built-In
Display: Color LCD, 2560 x 1600 Retina, Main, MirrorOff, Online
Memory Module: LPDDR4
AirPort: Wi-Fi, wl0: Oct 26 2021 16:10:41 version 18.20.310.15.7.8.120 FWID 01-5d6c3867
Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
USB Device: USB31Bus
USB Device: USB31Bus
Thunderbolt Bus: MacBook Air, Apple Inc.
Thunderbolt Bus: MacBook Air, Apple Inc.
jfversluis commented 2 years ago

~Reading through the logs I see~

~Error getting value from 'Id' on 'Models.Deserializable.DeserializableBase'~

~Isn't that the actual error? Something not being able to deserialize? Does this code work in a non-MAUI app?~

Ah I see, it does work in debug. Seems that maybe Newtonsoft.Json isn't linker safe?

ghost commented 2 years ago

Hi @nvdovkin. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

Kylar182 commented 2 years ago

~Reading through the logs I see~

~Error getting value from 'Id' on 'Models.Deserializable.DeserializableBase'~

~Isn't that the actual error? Something not being able to deserialize? Does this code work in a non-MAUI app?~

Ah I see, it does work in debug. Seems that maybe Newtonsoft.Json isn't linker safe?

First off, love your Channel.

Second, I have this or a similar issue on MAUI Mac. Full crash, doesn't even get caught in Try Catch for whatever reason. See the following Log.

  at <unknown> <0xffffffff>
  at <unknown> <0xffffffff>
  at System.Delegate:CreateDelegate_internal <0x0002e>
  at System.Delegate:CreateDelegate <0x00194>
  at System.Delegate:CreateDelegate <0x00026>
  at System.Delegate:CreateDelegate <0x00020>
  at System.Reflection.Emit.DynamicMethod:CreateDelegate <0x0008a>
  at System.Text.Json.Serialization.Metadata.ReflectionEmitMemberAccessor:CreateDelegate <0x00036>
  at System.Text.Json.Serialization.Metadata.ReflectionEmitMemberAccessor:CreatePropertyGetter <0x0001e>
  at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1:Initialize <0x0016e>
  at System.Text.Json.Serialization.Metadata.JsonTypeInfo:CreateProperty <0x0008c>
  at System.Text.Json.Serialization.Metadata.JsonTypeInfo:AddProperty <0x00156>
  at System.Text.Json.Serialization.Metadata.JsonTypeInfo:CacheMember <0x000a8>
  at System.Text.Json.Serialization.Metadata.JsonTypeInfo:.ctor <0x003b0>
  at System.Text.Json.Serialization.Metadata.JsonTypeInfo:.ctor <0x0004a>
  at System.Text.Json.JsonSerializerOptions:<InitializeForReflectionSerializer>g__CreateJsonTypeInfo|112_0 <0x00018>
  at System.Text.Json.JsonSerializerOptions:GetClassFromContextOrCreate <0x000c4>
  at System.Text.Json.JsonSerializerOptions:GetOrAddClass <0x00066>
  at System.Text.Json.Serialization.Metadata.JsonTypeInfo:get_ElementTypeInfo <0x0006a>
  at System.Text.Json.Serialization.JsonCollectionConverter`2:OnTryRead <0x0002a>
  at System.Text.Json.Serialization.JsonConverter`1:TryRead <0x0049a>
  at System.Text.Json.Serialization.JsonConverter`1:ReadCore <0x0025c>
  at System.Text.Json.JsonSerializer:ReadCore <0x00052>
  at System.Text.Json.JsonSerializer:ReadCore <0x0008c>
  at System.Text.Json.JsonSerializer:ContinueDeserialize <0x0018e>
  at <ReadAllAsync>d__65`1:MoveNext <0x00328>
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore:Start <0x0008c>
  at System.Runtime.CompilerServices.AsyncValueTaskMethodBuilder`1:Start <0x00010>
  at System.Text.Json.JsonSerializer:ReadAllAsync <0x00098>
  at System.Text.Json.JsonSerializer:DeserializeAsync <0x00064>
  at System.Net.Http.Json.HttpContentJsonExtensions:DeserializeAsyncHelper <0x0001e>
  at <ReadFromJsonAsyncCore>d__4`1:MoveNext <0x0021e>
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore:Start <0x0008c>
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start <0x00010>
  at System.Net.Http.Json.HttpContentJsonExtensions:ReadFromJsonAsyncCore <0x000ae>
  at System.Net.Http.Json.HttpContentJsonExtensions:ReadFromJsonAsync <0x000b0>
  at <GetAsync>d__0:MoveNext <0x00256>
  at AsyncStateMachineBox`1:ExecutionContextCallback <0x00024>
  at System.Threading.ExecutionContext:RunInternal <0x0011e>
  at AsyncStateMachineBox`1:MoveNext <0x000d0>
  at AsyncStateMachineBox`1:MoveNext <0x00014>
  at <>c:<.cctor>b__17_0 <0x00020>
  at System.Threading.Tasks.AwaitTaskContinuation:RunCallback <0x00084>
  at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run <0x00062>
  at System.Threading.Tasks.Task:RunContinuations <0x001c4>
  at System.Threading.Tasks.Task:FinishContinuations <0x00050>
  at System.Threading.Tasks.Task`1:TrySetResult <0x000de>
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetExistingTaskResult <0x0006a>
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult <0x00056>
  at <TryGet>d__2:MoveNext <0x0142e>
  at AsyncStateMachineBox`1:ExecutionContextCallback <0x00024>
  at System.Threading.ExecutionContext:RunInternal <0x0011e>
  at AsyncStateMachineBox`1:MoveNext <0x000d0>
  at AsyncStateMachineBox`1:MoveNext <0x00014>
  at <>c:<.cctor>b__8_0 <0x00020>
  at Foundation.NSAsyncSynchronizationContextDispatcher:Apply <0x0002e>
  at System.Object:runtime_invoke_direct_void__this__ <0x00080>
  at <unknown> <0x00000>
  at <unknown> <0xffffffff>
  at UIKit.UIApplication:UIApplicationMain <0x001c6>
  at UIKit.UIApplication:Main <0x0011c>
  at CompanyPortal.Components.Program:Main <0x00030>
  at <Module>:runtime_invoke_direct_void_string[] <0x00076>
  at <unknown> <0x00000>
NonameMissingNo commented 2 years ago

We're experiencing a similar issues with Json (Newtonsoft) encoding as well. (Attempting to get information from a website, and then retrieve it.)

mlancione commented 2 years ago

Experiencing the same issue. It works fine in the iOS simulator but fails when running on an iOS device.

Redth commented 2 years ago

@rolfbjarne or @steveisok is this an AOT issue? Thoughts?

steveisok commented 2 years ago

From the stack trace, it looks like it's trying to generate code a runtime, which is not a supported thing in AOT. My recommendation is to enable the interpreter and see if that fixes the problem.

nvdovkin commented 2 years ago

From the stack trace, it looks like it's trying to generate code a runtime, which is not a supported thing in AOT. My recommendation is to enable the interpreter and see if that fixes the problem.

The workaround by enabling interpreter does fix the issue. As the deserialization example is an generic one, i thought, it may be an AOT issue or issue with JSON.NET library. With System.Text.Json it seems to work without any workarounds

AlejandroRuiz commented 2 years ago

Im having the exact same issue it works on the next cases, the issue is just happening on Release signed build.

| ✅ | iOS Simulator Debug | ✅ | iOS Simulator Release | ✅ | iOS Device Debug | ✅ | iOS Device Release | ❌ | iOS Signed Release

If you want to make it work you can simple add this into your csproj

<UseInterpreter Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' And '$(Configuration)' == 'Release'">true</UseInterpreter>

not sure if this can impact sending the build to be distributed to the Store/TestFlight maybe someone from Microsoft can confirm @rolfbjarne @dalexsoto any thoughts?

rolfbjarne commented 2 years ago

@AlejandroRuiz that should work fine when published to the App Store. However, I'd recommend enabling the interpreter for all builds, not just Release builds, that way you test & debug what you're going to ship.

mattleibow commented 1 year ago

I am going to close this as the issue is mainly with json.net, however it may be a case that there is some use case in there that iOS is supposed to support but for some reason the code path is not going there. I do know the iOS team has done a bunch of work to hide the iOS limitations.

@rolfbjarne should we move this to macios? Or is this outside the bounds of the SDK at this point?

rolfbjarne commented 1 year ago

@rolfbjarne should we move this to macios? Or is this outside the bounds of the SDK at this point?

If anywhere this should be moved to dotnet/runtime, but this looks like a FullAOT limitation to me.