RevenueCat / purchases-kmp

RevenueCat SDK for Kotlin Multiplatform
MIT License
70 stars 2 forks source link

Crash after subscription iOS - class RCStoreTransaction cannot be cast to class StoreTransaction #168

Closed lopspower closed 2 weeks ago

lopspower commented 2 weeks ago

Describe the bug Crash of the iOS application just after a subscription on Emulator. Uncaught Kotlin exception: kotlin.ClassCastException: class RCStoreTransaction cannot be cast to class com.revenuecat.purchases.kmp.models.StoreTransaction

  1. Environment
    1. Platform:
    2. SDK version: 1.0.0-beta.3 & pod 13.0.1
    3. OS version: iOS 17.6.1
    4. IDE (e.g. Android Studio, Xcode, Fleet): Xcode
    5. IDE version: 15.4
    6. Device and/or emulator/simulator:
      • [x] Device
      • [x] Emulator/simulator
    7. Environment:
      • [x] Closed testing / Sandbox
      • [x] TestFlight
      • [ ] Production
    8. How widespread is the issue. Percentage of devices affected.
  2. Debug logs that reproduce the issue
  3. Steps to reproduce, with a description of expected vs. actual behavior
  4. Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)

Additional context

JayShortway commented 2 weeks ago

Thanks for reporting this issue! Which version of the SDK are you using? Can you share a full stack trace?

lopspower commented 2 weeks ago

Kotlin Version :

purchases-kmp = "1.0.0-beta.3"
purchases-core = { group = "com.revenuecat.purchases", name = "purchases-kmp-core", version.ref = "purchases-kmp" }
purchases-ui = { group = "com.revenuecat.purchases", name = "purchases-kmp-ui", version.ref = "purchases-kmp" }

Pod Version :

pod 'PurchasesHybridCommon', '13.0.1'
pod 'PurchasesHybridCommonUI', '13.0.1'

I don't have more stacktrace. I also tested on a physical device and I have the same problem. Once I relaunch the application, the user is subscribed. I'm a beginner on iOS, I can't remove the subscription afterwards as it's a sandbox test subscription which makes testing complicated. I did a test on Android and I have the same behavior. But here again, it's hard to get more logs because I have to go through the store with a closed test release. I use “revenuecatui.Paywall”. Crash occurs after subscription on this screen.

lopspower commented 2 weeks ago

With a new account I was able to generate a new stacktrace:


    at 0   MyApp                              0x1064278b3        kfun:kotlin.Throwable#<init>(kotlin.String?){} + 119 
    at 1   MyApp                              0x106420e9f        kfun:kotlin.Exception#<init>(kotlin.String?){} + 115 
    at 2   MyApp                              0x1064210bf        kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 115 
    at 3   MyApp                              0x106421a67        kfun:kotlin.ClassCastException#<init>(kotlin.String?){} + 115 
    at 4   MyApp                              0x10645d043        ThrowClassCastException + 535 
    at 5   MyApp                              0x107282a0b        kfun:com.revenuecat.purchases.kmp.ui.revenuecatui.IosPaywallDelegate#objc:paywallViewController:didFinishPurchasingWithCustomerInfo:transaction: + 435 
    at 6   MyApp                              0x1072835af        _636f6d2e726576656e75656361742e7075726368617365733a726576656e756563617475692f55736572732f64697374696c6c65722f70726f6a6563742f726576656e756563617475692f7372632f696f734d61696e2f6b6f746c696e2f636f6d2f726576656e75656361742f7075726368617365732f6b6d702f75692f726576656e756563617475692f50617977616c6c4f7074696f6e734b74782e6b74_knbridge4 + 275 
    at 7   MyApp                              0x104e00feb        $sTa.72 + 43 
    at 8   MyApp                              0x104dfbbb3        $s12RevenueCatUI21PaywallViewControllerC0aB012CustomerInfoCAD16StoreTransactionCSgIegyyy_AcfIIegggg_TR + 19 
    at 9   MyApp                              0x104dfbb47        $s12RevenueCatUI21PaywallViewControllerC013createHostingF033_866893E5163BBC6BC91A903C4AD9AFCFLL05SwiftC009UIHostingF0CyAA0d9ContainerE0AELLVGyFy0aB016StoreTransactionCSg_AL12CustomerInfoCtYbScMYccfU1_ + 979 
    at 10  MyApp                              0x1052a1fe7        $s12RevenueCatUI27OnPurchaseCompletedModifier33_E8A4BD3F3CCCBA8235368F4A78985CC3LLV4body7contentQr05SwiftC005_ViewG8_ContentVyADG_tFyAA28PurchasedResultPreferenceKeyV0eV0VSgcfU_ + 259 
    at 11  SwiftUI                             0x18d11c107        <redacted> + 660031 
    at 12  SwiftUI                             0x18d11c0df        <redacted> + 659991 
    at 13  SwiftUI                             0x18d0eca2b        <redacted> + 465763 
    at 14  SwiftUI                             0x18cf5357b        <redacted> + 137883 
    at 15  SwiftUI                             0x18cf50863        <redacted> + 126339 
    at 16  SwiftUI                             0x18cf4fedb        <redacted> + 123899 
    at 17  SwiftUI                             0x18ce7bb3f        <redacted> + 46139 
    at 18  SwiftUI                             0x18ce7b93b        <redacted> + 45623 
    at 19  SwiftUI                             0x18ce7b8af        <redacted> + 45483 
    at 20  SwiftUI                             0x18ce7b86b        <redacted> + 45415 
    at 21  Combine                             0x1922e54eb        <redacted> + 211 
    at 22  Combine                             0x1922e53b3        $s7Combine25ObservableObjectPublisherC4sendyyF + 651 
    at 23  Combine                             0x1922e4feb        <redacted> + 143 
    at 24  Combine                             0x1922e4bd3        $s7Combine9PublishedV18_enclosingInstance7wrapped7storagexqd___s24ReferenceWritableKeyPathCyqd__xGAHyqd__ACyxGGtcRld__CluisZ + 431 
    at 25  MyApp                               0x104e4372b        $s12RevenueCatUI15PurchaseHandlerC9purchasedSbvs + 143 
    at 26  MyApp                               0x104e4a62b        $s12RevenueCatUI15PurchaseHandlerC07performD07packagey0aB07PackageC_tYaKFyyXEfU_ + 47 
    at 27  MyApp                               0x104e4a653        $s12RevenueCatUI15PurchaseHandlerC07performD07packagey0aB07PackageC_tYaKFyyXEfU_TA + 19 
    at 28  SwiftUI                             0x18d05fbab        <redacted> + 28619 
    at 29  SwiftUI                             0x18d05fa8f        <redacted> + 28335 
    at 30  libswiftCore.dylib                  0x18780c093        $ss20withExtendedLifetimeyq_x_q_yKXEtKr0_lF + 27 
    at 31  SwiftUI                             0x18cf2bd77        <redacted> + 75687 
    at 32  SwiftUI                             0x18cf2bd03        <redacted> + 75571 
    at 33  MyApp                               0x104e4936f        $s12RevenueCatUI15PurchaseHandlerC07performD07packagey0aB07PackageC_tYaKFTY2_ + 355 
    at 34  libswift_Concurrency.dylib          0x194262763        <redacted> + 435 
    at 35  libswift_Concurrency.dylib          0x1942639c7        <redacted> + 71 
    at 36  libdispatch.dylib                   0x10ca6ac27        _dispatch_main_queue_drain + 779 
    at 37  libdispatch.dylib                   0x10ca6a90b        _dispatch_main_queue_callback_4CF + 43 
    at 38  CoreFoundation                      0x188eef70f        <redacted> + 15 
    at 39  CoreFoundation                      0x188eec913        <redacted> + 1995 
    at 40  CoreFoundation                      0x188eebcd7        CFRunLoopRunSpecific + 607 
    at 41  GraphicsServices                    0x1cd9391a7        GSEventRunModal + 163 
    at 42  UIKitCore                           0x18b525ae7        <redacted> + 887 
    at 43  UIKitCore                           0x18b5d9d97        UIApplicationMain + 339 
    at 44  SwiftUI                             0x18d0e0293        <redacted> + 414667 
    at 45  SwiftUI                             0x18d08c85f        <redacted> + 72087 
    at 46  SwiftUI                             0x18d09861b        <redacted> + 120659 
    at 47  MyApp                               0x1045252fb        $s6OP_TCG5OPTCGV5$mainyyFZ + 39 
    at 48  MyApp                               0x10452555f        main + 11 
    at 49  dyld                                0x1ac6c3153        <redacted> + 2355 ```
JayShortway commented 2 weeks ago

That's very valuable, thank you! I have opened a PR that should fix it: https://github.com/RevenueCat/purchases-kmp/pull/170. Will be in the next release.

If you can't wait for that, here are 2 options to avoid the crash now: