JSON Decoder crashes on Appstore/testflight but crash logs don't help

Here's what happen:

The app started to crash for some users (not all) on WatchOS 6+ with the latest watch os SDK from xcode 11 and 11.1 and when i switched to PackageManager from cocoa pods


I also see some crashes related to JSONDecoder with WatchOS 5 in another place


I debugged it in all the ways i can:

Installing from Xcode to my watch -> no crash

Installing from Xcode in release config to my watch --> no crash

Installing from Appstore/Tesflight --> crashes


I have tried this too: min watch deplyment target to 6 in Testflight --> crashes



I checked the swift open source code of the crashing function and it seems that abort is called because there is a superclass missing. But i still don't know what i need to fix on my end.



The crash has to do with JSONDecoder.decode then it asks my Class to init and crashes on the:

let container = try decoder.container(keyedBy: CodingKeys.self)



here's the crash log from some of my users:


Incident Identifier: 6FCDE9E0-BFDE-4E64-9434-AE627FDD70C1
CrashReporter Key:   35065bae376280654d740038ce69842829138cae
Hardware Model:      Watch3,2
Process:             Key for Tesla Extension [680]
Path:                /private/var/containers/Bundle/Application/4AEF8940-ADD5-4924-939A-6C8A0CC35ABE/Key for Tesla.app/PlugIns/Key for Tesla Extension.appex/Key for Tesla Extension
Identifier:          joao.Tesla-key.watchkitapp.watchkitextension
Version:             3 (1.8.2)
AppVariant:          1:Watch3,2:5.2
Code Type:           ARM (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           joao.Tesla-key.watchkitapp.watchkitextension [365]




Date/Time:           2019-10-13 14:33:21.2677 -0500
Launch Time:         2019-10-13 14:33:18.0000 -0500
OS Version:          Watch OS 6.0.1 (17R604)
Release Type:        User
Baseband Version:    4.00.00
Report Version:      104


Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  0


Thread 0 name:
Thread 0 Crashed:
0   libsystem_kernel.dylib         0x1acb2fc8 __pthread_kill + 8
1   libsystem_pthread.dylib       0x1ad2a3e2 pthread_kill + 88 (pthread.c:1456)
2   libsystem_c.dylib             0x1ac3c3a4 abort + 84 (abort.c:109)
3   libswiftCore.dylib             0x354103da swift::fatalError(unsigned int, char const*, ...) + 40 (Errors.cpp:353)
4   libswiftCore.dylib             0x3541dc1c getSuperclassMetadata(swift::TargetClassMetadata*, bool) + 474 (Metadata.cpp:2702)
5   libswiftCore.dylib             0x3541997c _swift_initClassMetadataImpl(swift::TargetClassMetadata*, swift::ClassLayoutFla... + 28 (Metadata.cpp:2739)
6   libswiftCore.dylib             0x3541a576 swift_initClassMetadata2 + 22 (Metadata.cpp:2839)
7   libswiftCore.dylib             0x353f1000 $ss26_KeyedDecodingContainerBoxCMr + 50 (:0)
8   libswiftCore.dylib             0x3541efb2 swift::MetadataCacheEntryBase<(anonymous namespace)::GenericCacheEntry, void const*>::doInitializ... + 178 (RelativePointer.h:518)
9   libswiftCore.dylib             0x354182fc swift_getGenericMetadata + 1124 (MetadataCache.h:920)
10  libswiftCore.dylib             0x352093c0 $ss22KeyedDecodingContainerVyAByxGqd__c3KeyQyd__Rszs0abC8ProtocolRd__lufC + 40 (:0)
11  libswiftFoundation.dylib       0x35528ada $s10Foundation13__JSONDecoder33_12768CA107A31EF2DCE034FD75B541C9LLC9container7keyedBys22KeyedDeco... + 678 (JSONEncoder.swift:1264)
12  libswiftFoundation.dylib       0x3557560c $s10Foundation13__JSONDecoder33_12768CA107A31EF2DCE034FD75B541C9LLCs7DecoderAAsAEP9container7keye... + 18
13  libswiftFoundation.dylib       0x3552af86 $s10Foundation13__JSONDecoder33_12768CA107A31EF2DCE034FD75B541C9LLCs7DecoderAAsAEP9container7keye... + 32
14  libswiftCore.dylib             0x353efad0 $ss7DecoderP9container7keyedBys22KeyedDecodingContainerVyqd__Gqd__m_tKs9CodingKeyRd__lFTj + 24
15  KeyKitWatch                   0x003c27b6 Vehicle.init(from:) + 858 (__hidden#3784_:59)
16  KeyKitWatch                   0x003c244a Vehicle.__allocating_init(from:) + 62 (__hidden#207_:0)
17  KeyKitWatch                   0x003c37b8 _hidden#3720_ + 14 (__hidden#207_:0)
18  libswiftCore.dylib             0x353efa5a $sSe4fromxs7Decoder_p_tKcfCTj + 12
19  libswiftFoundation.dylib       0x355418be $s10Foundation13__JSONDecoder33_12768CA107A31EF2DCE034FD75B541C9LLC6unbox__2asypSgyp_Se_pXptKF + 4014 (JSONEncoder.swift:2509)
20  libswiftFoundation.dylib       0x355284e6 $s10Foundation11JSONDecoderC6decode_4fromxxm_AA4DataVtKSeRzlF + 642 (JSONEncoder.swift:2484)
21  libswiftFoundation.dylib       0x355fcac8 $s10Foundation11JSONDecoderC6decode_4fromxxm_AA4DataVtKSeRzlFTj + 28
22  KeyKitWatch                   0x003a9292 String.decodeJSON() + 266 (__hidden#1362_:24)
23  KeyKitWatch                   0x0037996e KeyKit.lastVehicle.getter + 584 (KeyKit.swift:43)
24  KeyKitWatch                   0x0037ad60 KeyKit.credentialsReady() + 262 (KeyKit.swift:104)
25  Key for Tesla Extension       0x00239b22 InterfaceController.checkLogic() + 40 (InterfaceController.swift:168)
26  Key for Tesla Extension       0x002378e8 InterfaceController.willActivate() + 296 (InterfaceController.swift:54)
27  Key for Tesla Extension       0x00237914 @objc InterfaceController.willActivate() + 32 (:0)
28  WatchKit                       0x2a0bf99a -[SPRemoteInterface _activateViewController:clientIdentifier:] + 324 (SPRemoteInterface.m:3223)
29  WatchKit                       0x2a0fc4d8 -[WKInterfaceController _finishGestureInstallationWithCompletion:] + 316 (WKInterfaceController.m:218)
30  WatchKit                       0x2a0bf7de __61-[SPRemoteInterface activateViewController:clientIdentifier:]_block_invoke_2 + 124 (SPRemoteInterface.m:3201)
31  WatchKit                       0x2a0c26b6 -[SPRemoteInterface performAfterApplicationDidFinishLaunching:] + 40 (SPRemoteInterface.m:3689)
32  WatchKit                       0x2a0bf752 __61-[SPRemoteInterface activateViewController:clientIdentifier:]_block_invoke + 96 (SPRemoteInterface.m:3199)
33  WatchKit                       0x2a08d2bc spUtils_dispatchAsyncToMainThread + 22 (SPUtils.m:347)
34  WatchKit                       0x2a0bf64a -[SPRemoteInterface activateViewController:clientIdentifier:] + 158 (SPRemoteInterface.m:3198)
35  WatchKit                       0x2a13b622 __57-[SPExtensionConnection interfaceViewControllerActivate:]_block_invoke + 374 (SPExtensionConnection.m:1782)
36  WatchKit                       0x2a133d68 -[SPExtensionConnection performOnSendQueue:syncIfUnsuspended:] + 502 (SPExtensionConnection.m:0)
37  WatchKit                       0x2a13b44a -[SPExtensionConnection interfaceViewControllerActivate:] + 190 (SPExtensionConnection.m:1776)
38  WatchKit                       0x2a11fee4 -[SPApplicationDelegate viewControllerWillActivate:] + 142 (SPApplicationDelegate.m:2439)
39  WatchKit                       0x2a0ea6f4 -[SPViewController controllerWillActivate] + 214 (SPViewController.m:340)
40  WatchKit                       0x2a0a4b0a -[SPInterfaceViewController controllerWillActivate] + 314 (SPInterfaceViewController.m:1106)
41  WatchKit                       0x2a0a460a -[SPInterfaceViewController applicationDidBecomeActive] + 42 (SPInterfaceViewController.m:1043)
42  WatchKit                       0x2a118176 -[SPApplicationDelegate applicationDidBecomeActive:] + 670 (SPApplicationDelegate.m:1044)
43  UIKitCore                     0x32080e40 -[UIApplication _stopDeactivatingForReason:] + 1038 (UIApplication.m:1921)
44  UIKitCore                     0x31a4cc98 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransiti... + 76 (_UISceneLifecycleMultiplexer.m:566)
45  UIKitCore                     0x31dbe9cc _UIScenePerformActionsWithLifecycleActionMask + 64 (_UISceneLifecycleState.m:109)
46  UIKitCore                     0x31a4cbca __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransiti... + 158 (_UISceneLifecycleMultiplexer.m:499)
47  UIKitCore                     0x31a4c67c -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 106 (_UISceneLifecycleMultiplexer.m:451)
48  UIKitCore                     0x31a4ca6c -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionSto... + 636 (_UISceneLifecycleMultiplexer.m:498)
49  UIKitCore                     0x31a4c448 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 266 (_UISceneLifecycleMultiplexer.m:404)
50  UIKitCore                     0x31a4fba8 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsFo... + 136 (_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction.m:98)
51  UIKitCore                     0x31d1ad2c +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 770 (BSAnimationSettings+UIKit.m:50)
52  UIKitCore                     0x31dd56d6 _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 230 (_UISceneSettingsDiffAction.m:43)
53  UIKitCore                     0x31a4f9da __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsFo... + 114 (_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction.m:87)
54  UIKitCore                     0x31dd55e6 _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext + 78 (_UISceneSettingsDiffAction.m:35)
55  UIKitCore                     0x31a4f880 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUISc... + 296 (_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction.m:85)
56  UIKitCore                     0x319025d4 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 578 (UIScene.m:1410)
57  UIKitCore                     0x3190150c -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 190 (UIScene.m:1143)
58  UIKitCore                     0x3190235e -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 158 (UIScene.m:1387)
59  UIKitCore                     0x32086a60 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 516 (UIApplication.m:3700)
60  UIKitCore                     0x31d36ea4 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 302 (UIApplicationSceneClientAgent.m:45)
61  PepperUICore                   0x25039372 -[PUICApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 612 (PUICApplicationSceneClientAgent.m:129)
62  CarouselUIServices             0x285d6e90 -[CUISWatchKitApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 366 (CUISWatchKitApplicationSceneClientAgent.m:47)
63  FrontBoardServices             0x1e1f4930 -[FBSSceneImpl _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 414 (FBSSceneImpl.m:444)
64  FrontBoardServices             0x1e215790 __86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_... + 88 (FBSWorkspaceScenesClient.m:318)
65  FrontBoardServices             0x1e1fdc76 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 204 (FBSWorkspace.m:357)
66  FrontBoardServices             0x1e215500 __86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_... + 252 (FBSWorkspaceScenesClient.m:317)
67  libdispatch.dylib             0x1ab56448 _dispatch_client_callout + 6 (object.m:495)
68  libdispatch.dylib             0x1ab586bc _dispatch_block_invoke_direct + 180 (queue.c:463)
69  FrontBoardServices             0x1e235440 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 22 (FBSSerialQueue.m:173)
70  FrontBoardServices             0x1e235216 -[FBSSerialQueue _queue_performNextIfPossible] + 346 (FBSSerialQueue.m:216)
71  FrontBoardServices             0x1e23561e -[FBSSerialQueue _performNextFromRunLoopSource] + 24 (FBSSerialQueue.m:247)
72  CoreFoundation                 0x1afe0b28 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14 (CFRunLoop.c:1922)
73  CoreFoundation                 0x1afe0a7e __CFRunLoopDoSource0 + 84 (CFRunLoop.c:1956)
74  CoreFoundation                 0x1afe0442 __CFRunLoopDoSources0 + 140 (CFRunLoop.c:1992)
75  CoreFoundation                 0x1afdc4ba __CFRunLoopRun + 962 (CFRunLoop.c:2882)
76  CoreFoundation                 0x1afdbe5a CFRunLoopRunSpecific + 370 (CFRunLoop.c:3192)
77  GraphicsServices               0x1ddb6cd0 GSEventRunModal + 96 (GSEvent.c:2246)
78  UIKitCore                     0x3208a1fa UIApplicationMain + 1736 (UIApplication.m:4687)
79  libxpc.dylib                   0x1ad77dc0 _xpc_objc_main.cold.3 + 152
80  libxpc.dylib                   0x1ad68c04 _xpc_objc_main + 184 (main.m:108)
81  libxpc.dylib                   0x1ad6ab04 xpc_main + 110 (init.c:1568)
82  Foundation                     0x1b85c046 -[NSXPCListener resume] + 172 (NSXPCListener.m:276)
83  PlugInKit                     0x22958684 -[PKService run] + 384 (PKService.m:165)
84  WatchKit                       0x2a14d720 WKExtensionMain + 62 (main.m:19)
85  WatchKit                       0x2a14d734 main + 10 (main.m:27)
86  libdyld.dylib                 0x1ab91e52 start + 2


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

I’m not a Swift runtime expert but it seems likely that this error is

failed to demangle superclass of %s from mangled name '%s'
. You can find this on line 2620 of
Metadata.cpp
, which is darned close to line 2702 reported in frame 4 of your crash report [1].

That message suggests a name mangling mismatch, perhaps because different parts of your app were built with different Swift versions. However, that’s a lot of speculation on my part. My recommendation is that you repost your question over on Swift Forums > Using Swift to see if folks more familiar with the runtime have any input on this.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

[1] Close enough to reasonably assume that the difference is accounted for by drift in the code since the runtime was incorporated into watchOS 6.0.1. Getting absolute confirmation on this would require you to work out exactly what version of that file was built into the watchOS 6.0.1 runtime, and I’m not sure how to do that.

Hi, I have the exact same issue and I cannot figure our why it occurs. Do you have a solution to it? I would not like to strip out all JSONDecoder calls

I have this exact same issue, in two separate apps. Crashes on series 3 and 2 in the JSONDecoder, works fine on Series 4+ and only in the TestFlight build as you mentioned. I haven't been able to find a workaround yet.

I have the same issue .. Users with older Apple Watch devices are complaining that the app doesn't launch for them anymore.

I have the same issue, does anyone have any solution for this?
JSON Decoder crashes on Appstore/testflight but crash logs don't help
 
 
Q