dooboolab-community / react-native-iap

In App Purchase module for React Native!
https://react-native-iap.dooboolab.com
MIT License
2.79k stars 638 forks source link

EXC_BAD_ACCESS in RNIapIosSk2iOS15 #2645

Closed wkirby closed 1 week ago

wkirby commented 8 months ago

Please use the Discussion board if you want to get some help. Please use issues to report bugs.

Description

App errors on iOS startup with EXC_BAD_ACCESS on productStore in RNIapIosSk2iOS15.

Expected Behavior

App starts up without exception.

Screenshots

Environment:

To Reproduce Steps to reproduce the behavior:

Behavior appears on application launch.


Additional Context

Problem started happening after upgrading React Native from 0.72.4 to 0.73.1.

wkirby commented 8 months ago

Reverting my project back to an earlier commit, where we are running React Native 0.72.4 works as expected. Something appears to have changed between 0.72 and 0.73 which causes this issue.

wkirby commented 8 months ago

I went back and walked through each patch update form 0.72.4 to 0.73.1, changing nothing else about the project, and the problem does not appear. I'm currently working through updates on other packages 1 at a time to establish what causes this error to start happening.

I am doing so on 0.72.7, as 0.73.1 has some incompatibilities with other libraries in use by our app.

wkirby commented 8 months ago

Ok, on RN 0.72.7 with react-native-iap 12.10.8 everything is working, react-native-iap 12.12.1 throws the above EXC_BAD_ACCESS error

openpathgit commented 5 months ago

I also get bad_access crashes a lot on ios

Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x8000000000000010 -> 0x0000000000000010 (possible pointer authentication failure) Exception Codes: 0x0000000000000001, 0x8000000000000010 VM Region Info: 0x10 is not in any region. Bytes before following region: 68719476720 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START --->
commpage (reserved) 1000000000-7000000000 [384.0G] ---/--- SM=NUL ...(unallocated) Termination Reason: SIGNAL 11 Segmentation fault: 11 Terminating Process: exc handler [21763]

Triggered by Thread: 0

Thread 0 name: Thread 0 Crashed: 0 AppName 0x0000000102f0faa4 specialized Dictionary.subscript.getter + 0 (:0) 1 AppName 0x0000000102f0faa4 RNIapIos.resolvePromises(forKey:value:) + 92 (RNIapIos.swift:90) 2 AppName 0x0000000102f1449c closure #1 in RNIapIos.purchaseProcess(:) + 164 (RNIapIos.swift:522) 3 AppName 0x0000000102f1531c specialized closure #1 in RNIapIos.getPurchaseData(:withBlock:) + 1852 (RNIapIos.swift:797) 4 AppName 0x0000000102f15df4 specialized closure #1 in RNIapIos.getPurchaseData(:withBlock:) + 24 (RNIapIos.swift:813) 5 AppName 0x0000000102f15df4 RNIapIos.purchaseProcess(:) + 24 (:0) 6 AppName 0x0000000102f15df4 specialized RNIapIos.paymentQueue(:updatedTransactions:) + 2708 7 AppName 0x0000000102f148ac @objc RNIapIos.paymentQueue(:updatedTransactions:) + 128

wkirby commented 1 month ago

Coming back to this, as we now need to update the IAP library for android. I've tracked the problem to this PR: https://github.com/dooboolab-community/react-native-iap/pull/2518

Version 12.10.8 works just fine, 12.11.0 is broken before the application finishes launching. I am not a Swift expert by any stretch, but I suspect that there's something about our XCode project and the storekit configuration.

@arthurgeron any chance you have insight on this?

wkirby commented 1 month ago

I have stripped out my entire storekit configuration, and removed every piece of javascript related to react-native-iap and I am still encountering this error, just by virtue of having the react-native-iap pod installed in our project.

I took some time to delve into the EXC_BAD_ACCESS error in Swift, and it appears to be something related to concurrency. My new guess, since this library appears to work for other people, is that there is something about the configuration of our application that is causing the issue, but I'm at a total loss on how to continue debugging.

wkirby commented 1 week ago

I'm giving up. What finally resolved this issue was to initialize a new, empty React Native project and copy my configuration and JS code over to the new project. Nothing about my dependencies or JS source changed, and now it works.

Here's my assumption: somewhere in the long road of upgrades from ~0.62 to 0.74, something deep within the internals of the XCode project either didn't migrate correctly, or wasn't included in the migration process, and only surfaced with the Swift changes identified in #2518.

Anyway, I'm closing this issue – if someone else finds this, try just starting over.