tikhop / TPInAppReceipt

Reading and Validating In App Purchase Receipt Locally.
MIT License
631 stars 93 forks source link

InAppReceipt.localReceipt() - Crashed! #27

Closed weizenberg closed 5 years ago

weizenberg commented 5 years ago

Hello, The lib crashing at the 2.0.6 version for some users. Attaching the crash log:

0 TPInAppReceipt $s10Foundation4DataV15_RepresentationOyACSnySiGcigTf4xn_n + 672
1 TPInAppReceipt $s14TPInAppReceipt10ASN1ObjectV13extractLenght4fromAC6LengthO10Foundation4DataVz_tKFZTf4nd_n + 280
2 TPInAppReceipt $s14TPInAppReceipt10ASN1ObjectV11isDataValid14checkingLength_S2b_10Foundation0G0VztFZTf4nnd_n + 136
3 TPInAppReceipt $s14TPInAppReceipt10ASN1ObjectV5value33_FC213C5763315B30AA3A82B9DB6D97D1LLAA0D21ExtractableValueTypes_pSgyF + 1868
4 TPInAppReceipt $s14TPInAppReceipt02InbC7PayloadV8asn1DataAC10Foundation0G0VtcfcyAA0dbC9AttributeVXEfU + 268
5 TPInAppReceipt $s14TPInAppReceipt10ASN1ObjectV011enumerateInbC10Attributes4withyyAA0gbC9AttributeVXE_tF04$s14ab62Receipt02InbC7PayloadV8asn1DataAC10Foundation0G0V_tcfcyAA0dbC9J6VXEfU_SS10Foundation0Q0VSSA2KSayAA0gB8PurchaseVGS2SSgSSTf1cn_n + 512
6 TPInAppReceipt $s14TPInAppReceipt02InbC7PayloadV8asn1DataAC10Foundation0G0V_tcfCTf4gd_n + 432
7 TPInAppReceipt $s14TPInAppReceipt02InbC0V05localC0ACyKFZ + 260
tikhop commented 5 years ago

@weizenberg Thanks for reporting, I will upload a fix on cocoapods in a bit.

tikhop commented 5 years ago

@weizenberg while it's being publishing you can try the last version pod 'TPInAppReceipt', :git => 'https://github.com/tikhop/TPInAppReceipt.git', :branch => :master

tikhop commented 5 years ago

Version 2.1.0 has been released. It should contain a fix.

b-onc commented 5 years ago

Hello @tikhop , thank you for your hard work! We're at the latest version (2.1.2) and we get random crashes at let receipt = try InAppReceipt.localReceipt(). No specific device/OS version (no iOS13). We couldn't reproduce them yet. We're symbolicating crashes and will get you missing symbols ASAP. In the meantime, can you make anything from this log?

0  libsystem_kernel.dylib         0x2192d20dc __pthread_kill + 8
1  libsystem_pthread.dylib        0x21934b094 pthread_kill$VARIANT$mp + 380
2  libsystem_c.dylib              0x21922bea8 abort + 140
3  libswiftCore.dylib             0x2472b82a8 swift_vasprintf(char**, char const*, char*) + 54
4  libswiftCore.dylib             0x2472b09b4 swift::swift_dynamicCastFailure(swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, char const*) + 74
5  libswiftCore.dylib             0x2472b0a2c swift::_conformsToProtocol(swift::OpaqueValue const*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptorRef<swift::InProcess>, swift::TargetWitnessTable<swift::InProcess> const**) + 118
6  libswiftCore.dylib             0x2472b25b8 swift_dynamicCastImpl(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, swift::DynamicCastFlags) + 3628
7  libswiftCore.dylib             0x2472b36ac _dynamicCastFromExistential(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetExistentialTypeMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, swift::DynamicCastFlags) + 312
8  TPInAppReceipt                 0x103f47cc8 (Missing)
9  TPInAppReceipt                 0x103f3814c (Missing)
10 TPInAppReceipt                 0x103f4859c (Missing)
11 TPInAppReceipt                 0x103f48eac (Missing)

UPDATE: Here's the symbolicated crash log

0  TPInAppReceipt                 0x1022e0104 closure #1 in InAppReceiptPayload.init(asn1Data:) + 95 (InAppReceiptPayload.swift:95)
1  TPInAppReceipt                 0x1022d014c specialized ASN1Object.enumerateInAppReceiptAttributes(with:) + 53 (<compiler-generated>:53)
2  TPInAppReceipt                 0x1022e059c specialized InAppReceiptPayload.init(asn1Data:) + 112 (InAppReceiptPayload.swift:112)
3  TPInAppReceipt                 0x1022e0eac static InAppReceipt.localReceipt() + 56 (InAppReceipt.swift:56)

Could not cast value of type 'TPInAppReceipt.ASN1Object' (0x10581ca78) to 'Foundation.Data' (0x1f1e90d90).

tikhop commented 5 years ago

Hello @b-onc, thanks for posting an issue. I'll take a look in a bit. Meanwhile, is there a chance that you can provide your receipt in order to debug it?

tikhop commented 5 years ago

@b-onc I've push some fix which may solve your issue. Can you try to instal pod from master branch:

pod 'TPInAppReceipt', :git => 'https://github.com/tikhop/TPInAppReceipt.git', :branch => :master

Thank you.

b-onc commented 5 years ago

Thank you for the quick response, @tikhop . We're trying the master branch and will get back to you as soon as we have more info. We'll try to provide receipt data too.

tikhop commented 5 years ago

@b-onc Sounds good. Thank you!

b-onc commented 5 years ago

Hello @tikhop ! We are trying to write a unit test to check if some of the receipts we have are being correctly parsed by the pod. The base64encoded receipt I'll add below crashes at InAppReceiptPayload:76 with error Unexpectedly found nil, the type property of InAppReceiptAttribute is nil. This is not the crash we're seeing in the wild, although I don't know why it happens. Can you please check?

Thank you!

deleted

tikhop commented 5 years ago

@b-onc pushed a fix

tikhop commented 5 years ago

@b-onc I've released a new version and been using it for some time for my current project — seems to be working well.

Does the last fix work for you?

b-onc commented 5 years ago

Hello @tikhop , I'm testing the latest version you've pushed, and it's crashing for the receipts I'll attach below. InAppReceiptPayload:93, Could not cast value of type 'TPInAppReceipt.ASN1Object' (0x10dcb2038) to 'Foundation.Data' (0x1128d34f8).

Receipts: Can you send me an email at bahadir.oencel@fretello.com so I can share more receipts?

tikhop commented 5 years ago

Hello @b-onc,

Thanks for providing more receipts. I was able to reproduce the issue and It has been fixed in the last commit and release.

I have checked all your receipts and mine too — works well.

Thanks again.

b-onc commented 5 years ago

Hello @tikhop All 2309 receipts we have parse correctly with the latest release (2.1.2) This can be closed now.

Thank you for all the help!

tikhop commented 5 years ago

@b-onc Awesome! Thanks for collaborating, helped a lot.