RevenueCat / purchases-kmp

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

Crash when displaying paywall without explicitly providing offering #128

Closed MrJohn10 closed 2 months ago

MrJohn10 commented 2 months ago

When showing paywall using this code:

val options = PaywallOptions(dismissRequest = { })
Paywall(options)

the app crashes with:

Uncaught Kotlin exception: kotlin.UninitializedPropertyAccessException: lateinit property component has not been initialized

When providing offering in the paywall options, it works.

var paywallOffering by remember { mutableStateOf<Offering?>(null) }

    LaunchedEffect(Unit) {
        Purchases.configure(getPurchasesApiKey())
        val offerings = Purchases.sharedInstance.awaitOfferings()
        paywallOffering = offerings.current
    }

    if (paywallOffering != null) {
        val options = PaywallOptions(dismissRequest = { onDismiss() }) {
            offering = paywallOffering
            shouldDisplayDismissButton = displayDismissButton
        }
        Paywall(options)
    }
  1. Environment
    1. Platform:
    2. SDK version: 1.0.0-beta.1
    3. OS version: 14.5 (23F79)
    4. IDE (e.g. Android Studio, Xcode, Fleet): Android Studio, Xcode
    5. IDE version:
    6. Device and/or emulator/simulator:
      • [x] Device
      • [x] Emulator/simulator
    7. Environment:
      • [x] Closed testing / Sandbox
      • [x] TestFlight
      • [x] Production
  2. Debug logs that reproduce the issue
2024-07-11 19:55:13.244710+0200 facememo[24763:8626406] [receipt] INFO: ℹ️ Parsing receipt
2024-07-11 19:55:13.541817+0200 facememo[24763:8626406] [receipt] INFO: ℹ️ Receipt parsed successfully
Uncaught Kotlin exception: kotlin.UninitializedPropertyAccessException: lateinit property component has not been initialized
    at 0   facememo                            0x1014cb60f        kfun:kotlin.Throwable#<init>(kotlin.String?){} + 119 
    at 1   facememo                            0x1014c4b1b        kfun:kotlin.Exception#<init>(kotlin.String?){} + 115 
    at 2   facememo                            0x1014c4d3b        kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 115 
    at 3   facememo                            0x1014c5c83        kfun:kotlin.UninitializedPropertyAccessException#<init>(kotlin.String?){} + 115 
    at 4   facememo                            0x1015022c3        kfun:kotlin.native.internal#ThrowUninitializedPropertyAccessException(kotlin.String){}kotlin.Nothing + 367 
    at 5   facememo                            0x10227991b        kfun:androidx.compose.ui.interop.EmbeddedInteropComponent.<get-component>#internal + 199 
    at 6   facememo                            0x10227d04f        kfun:androidx.compose.ui.interop.UIKitViewController$lambda$26$lambda$25#internal + 383 
    at 7   facememo                            0x10227fd63        kfun:androidx.compose.ui.interop.$UIKitViewController$lambda$26$lambda$25$FUNCTION_REFERENCE$30.invoke#internal + 79 
    at 8   facememo                            0x10227fe8b        kfun:androidx.compose.ui.interop.$UIKitViewController$lambda$26$lambda$25$FUNCTION_REFERENCE$30.$<bridge-UNN>invoke(){}#internal + 71 
    at 9   facememo                            0x101606ae7        kfun:kotlin.Function0#invoke(){}1:0-trampoline + 99 
    at 10  facememo                            0x1022f5173        kfun:androidx.compose.ui.window.MetalRedrawer.draw$lambda$4#internal + 2819 
    at 11  facememo                            0x1022f685f        kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$4$FUNCTION_REFERENCE$4.invoke#internal + 103 
    at 12  facememo                            0x1022f6a4b        kfun:androidx.compose.ui.window.MetalRedrawer.$draw$lambda$4$FUNCTION_REFERENCE$4.$<bridge-UNN>invoke(){}#internal + 71 
    at 13  facememo                            0x101606ae7        kfun:kotlin.Function0#invoke(){}1:0-trampoline + 99 
    at 14  facememo                            0x1022f2473        kfun:androidx.compose.ui.window.MetalRedrawer.draw#internal + 7271 
    at 15  facememo                            0x1022f4193        kfun:androidx.compose.ui.window.MetalRedrawer.<init>$lambda$0#internal + 435 
    at 16  facememo                            0x1022f62c7        kfun:androidx.compose.ui.window.MetalRedrawer.$<init>$lambda$0$FUNCTION_REFERENCE$0.invoke#internal + 71 
    at 17  facememo                            0x1022f6397        kfun:androidx.compose.ui.window.MetalRedrawer.$<init>$lambda$0$FUNCTION_REFERENCE$0.$<bridge-UNN>invoke(){}#internal + 71 
    at 18  facememo                            0x101606ae7        kfun:kotlin.Function0#invoke(){}1:0-trampoline + 99 
    at 19  facememo                            0x1022f70df        kfun:androidx.compose.ui.window.DisplayLinkProxy.handleDisplayLinkTick#internal + 151 
    at 20  facememo                            0x1022f7193        kfun:androidx.compose.ui.window.DisplayLinkProxy.$imp:handleDisplayLinkTick#internal + 143 
    at 21  QuartzCore                          0x1998b7ecb        <redacted> + 47 
    at 22  QuartzCore                          0x1998b622f        <redacted> + 875 
    at 23  QuartzCore                          0x1998b5dcf        <redacted> + 351 
    at 24  UIKitCore                           0x19a4ad76b        <redacted> + 83 
    at 25  UIKitCore                           0x19a4ad3af        <redacted> + 171 
    at 26  UIKitCore                           0x19a4ae253        <redacted> + 91 
    at 27  CoreFoundation                      0x1981cb833        <redacted> + 27 
    at 28  CoreFoundation                      0x1981cb7c7        <redacted> + 175 
    at 29  CoreFoundation                      0x1981c9297        <redacted> + 243 
    at 30  CoreFoundation                      0x1981c8483        <redacted> + 827 
    at 31  CoreFoundation                      0x1981c7cd7        CFRunLoopRunSpecific + 607 
    at 32  GraphicsServices                    0x1dd0781a7        GSEventRunModal + 163 
    at 33  UIKitCore                           0x19a80090b        <redacted> + 887 
    at 34  UIKitCore                           0x19a8b49cf        UIApplicationMain + 339 
    at 35  SwiftUI                             0x19c3b8147        <redacted> + 414603 
    at 36  SwiftUI                             0x19c364713        <redacted> + 72023 
    at 37  SwiftUI                             0x19c3704cf        <redacted> + 120595 
    at 38  facememo                            0x100fccac3        $s8facememo0A3AppV5$mainyyFZ + 39 
    at 39  facememo                            0x100fccb6f        main + 11 
    at 40  dyld                                0x1bb879e4b        <redacted> + 2239
  1. Expected behavior Paywall should fetch offering implicitly, like it works on android. If that's not possible for whatever reason, we should make the offering argument in the paywall options object to be mandatory. Documentation also shows code that doesn't fetch offerings: docs
JayShortway commented 2 months ago

Thanks for reporting! This seems like it should not be happening indeed. We'll investigate and report back.

JayShortway commented 2 months ago

Was able to reproduce and fix. This will be in the next (beta) release. Thanks again for the bug report!