iOS Crash Report SKProductsRequest
Asked Answered
S

1

10

Could someone confirm my thinking that the following crash report would be generated due to SKProductsRequestDelegate still being allocated, yet the code itself not being? i.e. the VC has been closed?

StoreKit: __34-[SKProductsRequest _handleReply:]_block_invoke + 442

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x41682340
Triggered by Thread:  0

Thread 0 Crashed:
0   libobjc.A.dylib                 0x38d19626 objc_msgSend + 6
1   StoreKit                        0x30c4784a __34-[SKProductsRequest _handleReply:]_block_invoke + 442
2   libdispatch.dylib               0x391f7830 _dispatch_call_block_and_release + 8
3   libdispatch.dylib               0x391f781c _dispatch_client_callout + 20
4   libdispatch.dylib               0x391fe49a _dispatch_main_queue_callback_4CF$VARIANT$mp + 274
5   CoreFoundation                  0x2e45f89c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 4
6   CoreFoundation                  0x2e45e170 __CFRunLoopRun + 1296
7   CoreFoundation                  0x2e3c8eba CFRunLoopRunSpecific + 518
8   CoreFoundation                  0x2e3c8c9e CFRunLoopRunInMode + 102
9   GraphicsServices                0x3332265e GSEventRunModal + 134
10  UIKit                           0x30d15148 UIApplicationMain + 1132
11  BaseApp                         0x00035aea 0x2c000 + 39658
12  libdyld.dylib                   0x3921cab4 start + 0

If my thinking is correct, can I resolve this by calling:-

request.delegate = nil;
[request cancel];
request = nil;

If I am incorrect, could someone shed some more light on this for me?

Thanks.

Stier answered 10/7, 2014 at 11:36 Comment(0)
S
24

For ref, my addition of the following code did indeed rectify the issue.

request.delegate = nil;
[request cancel];
request = nil;
Stier answered 27/8, 2014 at 17:1 Comment(5)
Where did you put that? Don't understand.Alberik
Add it as the class is being removed, so viewWillDisappear, dealloc, or any backgrounding.Stier
Ah ya I got it. Eventually I realized that object was just deallocing while the call was being made so I moved it. Thanks!Alberik
Thank you. It seems SKProductRequest stores the delegate in an ivar while processing the response, thus nil'ing the delegate at -request:didReceiveResponse: does not help. I resorted to storing the response object and dispatching at -requestDidFinish: delegate insteadVagabondage
@Voxar, can you show me that code snippet for requestDidFinishTransference

© 2022 - 2024 — McMap. All rights reserved.