Peter-Schorn / SpotifyAPI

A Swift library for the Spotify web API. Supports all endpoints.
https://peter-schorn.github.io/SpotifyAPI/documentation/spotifywebapi
MIT License
269 stars 33 forks source link

App crashes upon closing and re-opening after authorization #52

Closed charlottemoche closed 1 year ago

charlottemoche commented 1 year ago

hello again. thank you for this library, it's been great!

i am having an issue where when i close my app to test the re-opening with authorization, it is crashing. i added some breakpoints and i cannot figure out when exactly it is crashing.

i based it off of the sample app

when i first open at run, i can see

Initializing Spotify...
found authorization information in keychain
Initialization complete
Spotify.authorizationManagerDidChange: isAuthorized: true
[APIRequest: trace: apiRequest(url:httpMethod:makeHeaders:bodyData:requiredScopes:) line 138] GET request to "https://api.spotify.com/v1/me"
did save authorization manager to keychain

if i just switch to a different app and go back it is fine. it's only when i close out of it.

see crash logs below


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

Triggered by Thread:  0

Thread 0 name:   Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libswiftCore.dylib                     0x199039870 _assertionFailure(_:_:file:line:flags:) + 264
1   Personify                              0x102b812d8 closure #1 in variable initialization expression of static Spotify.clientId + 536
2   Personify                              0x102b810a4 one-time initialization function for clientId + 36
3   libdispatch.dylib                      0x1a7b69300 _dispatch_client_callout + 19
4   libdispatch.dylib                      0x1a7b6ab3c _dispatch_once_callout + 31
5   Personify                              0x102b8132c Spotify.clientId.unsafeMutableAddressor + 80
6   Personify                              0x102b84ddc Spotify.init() + 1796
7   Personify                              0x102b846cc Spotify.__allocating_init() + 44
8   Personify                              0x102b76c50 implicit closure #2 in implicit closure #1 in variable initialization expression of PersonifyApp._spotify + 44
9   SwiftUI                                0x1a463b73c 0x1a463b6cd + 111
10  SwiftUI                                0x1a40f22a8 0x1a40f20ed + 443
11  SwiftUI                                0x1a40f19b4 0x1a40f194d + 103
12  SwiftUI                                0x1a51bbbe8 0x1a51bbb81 + 103
13  SwiftUI                                0x1a51bbc28 0x1a51bbc0d + 27
14  libswiftCore.dylib                     0x19904d100 withUnsafeMutablePointer<A, B>(to:_:) + 27
15  SwiftUI                                0x1a51bba7c 0x1a51bb8f9 + 387
16  SwiftUI                                0x1a51bb6a4 0x1a51bb40d + 663
17  SwiftUI                                0x1a4bc3b0c 0x1a4bc3aed + 31
18  AttributeGraph                         0x1c7981854 AG::Graph::UpdateStack::update() + 511
19  AttributeGraph                         0x1c7978504 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 423
20  AttributeGraph                         0x1c7977ddc AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, unsigned int, AGSwiftMetadata const*, unsigned char&, long) + 719
21  AttributeGraph                         0x1c7977970 AGGraphGetValue + 227
22  SwiftUI                                0x1a51baa68 0x1a51baa15 + 83
23  SwiftUI                                0x1a51bb070 0x1a51bae7d + 499
24  SwiftUI                                0x1a51bac54 0x1a51baaf5 + 351
25  SwiftUI                                0x1a4bc3b0c 0x1a4bc3aed + 31
26  AttributeGraph                         0x1c7981854 AG::Graph::UpdateStack::update() + 511
27  AttributeGraph                         0x1c7978504 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 423
28  AttributeGraph                         0x1c7977ddc AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, unsigned int, AGSwiftMetadata const*, unsigned char&, long) + 719
29  AttributeGraph                         0x1c7977970 AGGraphGetValue + 227
30  SwiftUI                                0x1a3fa5dcc 0x1a3fa5d7d + 79
31  SwiftUI                                0x1a3fa5f0c 0x1a3fa5e29 + 227
32  SwiftUI                                0x1a4bc3b0c 0x1a4bc3aed + 31
33  AttributeGraph                         0x1c7981854 AG::Graph::UpdateStack::update() + 511
34  AttributeGraph                         0x1c7978504 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 423
35  AttributeGraph                         0x1c797fb4c AG::Graph::value_ref(AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&) + 287
36  AttributeGraph                         0x1c79779c0 AGGraphGetValue + 307
37  SwiftUI                                0x1a5460964 0x1a5460921 + 67
38  SwiftUI                                0x1a401e98c 0x1a401e8ad + 223
39  SwiftUI                                0x1a40191e8 0x1a4018c2d + 1467
40  SwiftUI                                0x1a401a5e0 0x1a401a57d + 99
41  UIKitCore                              0x1a1f6289c +[UIScene _sceneForFBSScene:create:withSession:connectionOptions:] + 1079
42  UIKitCore                              0x1a201f8c8 -[UIApplication _connectUISceneFromFBSScene:transitionContext:] + 807
43  UIKitCore                              0x1a201f3f0 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 359
44  UIKitCore                              0x1a201f21c -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 287
45  FrontBoardServices                     0x1b7e4b6d4 -[FBSScene _callOutQueue_didCreateWithTransitionContext:completion:] + 323
46  FrontBoardServices                     0x1b7e4b570 __92-[FBSWorkspaceScenesClient createSceneWithIdentity:parameters:transitionContext:completion:]_block_invoke.108 + 279
47  FrontBoardServices                     0x1b7e4a19c -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 167
48  FrontBoardServices                     0x1b7e55f8c __92-[FBSWorkspaceScenesClient createSceneWithIdentity:parameters:transitionContext:completion:]_block_invoke + 351
49  libdispatch.dylib                      0x1a7b69300 _dispatch_client_callout + 19
50  libdispatch.dylib                      0x1a7b6cd48 _dispatch_block_invoke_direct + 283
51  FrontBoardServices                     0x1b7e46520 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 51
52  FrontBoardServices                     0x1b7e464a0 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible] + 239
53  FrontBoardServices                     0x1b7e46378 -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource] + 27
54  CoreFoundation                         0x19fbe331c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 27
55  CoreFoundation                         0x19fbe2598 __CFRunLoopDoSource0 + 175
56  CoreFoundation                         0x19fbe0dac __CFRunLoopDoSources0 + 339
57  CoreFoundation                         0x19fbdfa88 __CFRunLoopRun + 827
58  CoreFoundation                         0x19fbdf668 CFRunLoopRunSpecific + 607
59  GraphicsServices                       0x1e2faa5ec GSEventRunModal + 163
60  UIKitCore                              0x1a1ffc2b4 -[UIApplication _run] + 887
61  UIKitCore                              0x1a1ffb8f0 UIApplicationMain + 339
62  SwiftUI                                0x1a49fe0fc 0x1a49fe04d + 175
63  SwiftUI                                0x1a49fdf40 0x1a49fdea9 + 151
64  SwiftUI                                0x1a466f868 0x1a466f7e9 + 127
65  Personify                              0x102b772b8 static PersonifyApp.$main() + 40
66  Personify                              0x102b77398 main + 12
67  dyld                                   0x1c2632dcc start + 2239

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

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

Thread 3:
0   libsystem_pthread.dylib                0x2096099fc start_wqthread + 0

Thread 4:
0   libsystem_pthread.dylib                0x2096099fc start_wqthread + 0

Thread 5 name:  com.apple.uikit.eventfetch-thread
Thread 5:
0   libsystem_kernel.dylib                 0x1e70b81d8 mach_msg2_trap + 8
1   libsystem_kernel.dylib                 0x1e70b7f70 mach_msg2_internal + 79
2   libsystem_kernel.dylib                 0x1e70b7e88 mach_msg_overwrite + 435
3   libsystem_kernel.dylib                 0x1e70b7cc8 mach_msg + 23
4   CoreFoundation                         0x19fbe1d0c __CFRunLoopServiceMachPort + 159
5   CoreFoundation                         0x19fbdfc04 __CFRunLoopRun + 1207
6   CoreFoundation                         0x19fbdf668 CFRunLoopRunSpecific + 607
7   Foundation                             0x19eb7854c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 211
8   Foundation                             0x19eba627c -[NSRunLoop(NSRunLoop) runUntilDate:] + 63
9   UIKitCore                              0x1a1f5dfc8 -[UIEventFetcher threadMain] + 419
10  Foundation                             0x19ebfd184 __NSThread__start__ + 731
11  libsystem_pthread.dylib                0x20960a4d4 _pthread_start + 135
12  libsystem_pthread.dylib                0x209609a10 thread_start + 7

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

Thread 7:
0   libsystem_pthread.dylib                0x2096099fc start_wqthread + 0

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x80000001031768c0   x1: 0x0000000000000000   x2: 0xfffffffffffffff0   x3: 0x0000000282f28330
    x4: 0x0000000282f28380   x5: 0x000000016d2bb550   x6: 0x0000000000000073   x7: 0x0000000000000000
    x8: 0x00000000000000cc   x9: 0x00000000000000cb  x10: 0x0000000000000320  x11: 0x00000000e3e2901a
   x12: 0x00000000000007fb  x13: 0x00000000000007fd  x14: 0x00000000e402980b  x15: 0x000000000000000b
   x16: 0x00000000e3e2901a  x17: 0x0000000000029800  x18: 0x0000000000000000  x19: 0x0000000103197660
   x20: 0x80000001031768c0  x21: 0x0000000000000000  x22: 0x000000000000000b  x23: 0x0000000000000017
   x24: 0x000000000000001d  x25: 0x00000001031764a0  x26: 0xd000000000000033  x27: 0x0000000000000000
   x28: 0x00000001f0c29ee8   fp: 0x000000016d2bb730   lr: 0x0000000199039870
    sp: 0x000000016d2bb660   pc: 0x0000000199039870 cpsr: 0x60001000
   far: 0x0000000000000000  esr: 0xf2000001 (Breakpoint) brk 1
charlottemoche commented 1 year ago

can confirm that my CLIENT_ID and CLIENT_SECRET are set in the scheme