react-native-purchases icon indicating copy to clipboard operation
react-native-purchases copied to clipboard

Android Crashes with ViewTreeLifecycleOwner not found from android.widget.FrameLayout

Open HilSny opened this issue 5 months ago • 5 comments

Describe the bug When using the <RevenueCatUI.Paywall> component android crashes with the following

**    <Modal
      animationIn="slideInUp"
      animationInTiming={350}
      animationOut="slideOutDown"
      animationOutTiming={350}
      backdropColor={palette.slate100}
      onAccessibilityEscape={onClose}
      onBackButtonPress={onClose}
      onBackdropPress={onClose}
      onSwipeComplete={onClose}
      backdropOpacity={0.7}
      isVisible={isVisible}
      deviceWidth={width}
      deviceHeight={height}
      style={{
        borderTopLeftRadius: 24,
        borderTopRightRadius: 24,
        backgroundColor: palette.inverted,
        margin: 0,
        marginTop: 60,
        // padding: 16,
        paddingTop: 30,
      }}
    >
      <RevenueCatUI.Paywall
        onPurchaseCompleted={handlePurchase}
        onDismiss={onClose}
        options={{ displayCloseButton: true }}
      />
    </Modal>

**

FATAL EXCEPTION: main
                                                                                                    Process: com.stridekick.Stridekick.dev, PID: 14526
                                                                                                    java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from android.widget.FrameLayout{fa35aa8 V.E...... ......I. 0,0-0,0}
                                                                                                    	at androidx.compose.ui.internal.InlineClassHelperKt.throwIllegalStateExceptionForNullCheck(InlineClassHelper.kt:30)
                                                                                                    	at androidx.compose.ui.platform.WindowRecomposer_androidKt.createLifecycleAwareWindowRecomposer(WindowRecomposer.android.kt:466)
                                                                                                    	at androidx.compose.ui.platform.WindowRecomposer_androidKt.createLifecycleAwareWindowRecomposer$default(WindowRecomposer.android.kt:327)
                                                                                                    	at androidx.compose.ui.platform.WindowRecomposerFactory$Companion.LifecycleAware$lambda$0(WindowRecomposer.android.kt:170)
                                                                                                    	at androidx.compose.ui.platform.WindowRecomposerFactory$Companion.$r8$lambda$PmWZXv-2LDhDmANvYhil4YZYJuQ(Unknown Source:0)
                                                                                                    	at androidx.compose.ui.platform.WindowRecomposerFactory$Companion$$ExternalSyntheticLambda0.createRecomposer(Unknown Source:0)
                                                                                                    	at androidx.compose.ui.platform.WindowRecomposerPolicy.createAndInstallWindowRecomposer$ui_release(WindowRecomposer.android.kt:226)
                                                                                                    	at androidx.compose.ui.platform.WindowRecomposer_androidKt.getWindowRecomposer(WindowRecomposer.android.kt:302)
                                                                                                    	at androidx.compose.ui.platform.AbstractComposeView.resolveParentCompositionContext(ComposeView.android.kt:251)
                                                                                                    	at androidx.compose.ui.platform.AbstractComposeView.ensureCompositionCreated(ComposeView.android.kt:258)
                                                                                                    	at androidx.compose.ui.platform.AbstractComposeView.onAttachedToWindow(ComposeView.android.kt:290)
  1. Environment

    1. Platform: Android/React-Native
    2. SDK version: 8.11.8
    3. React Native version: 71
    4. How widespread is the issue. Percentage of devices affected: all
  2. Steps to reproduce, with a description of expected vs. actual behavior Try to open the paywall component.

Overall the solution of using the presentPaywall function (which is what I've seen others recommend) is not good enough. It doesn't contain the hooks for "onPurchaseCompleted'. If that method mimicked the ui component we would love to use it. As it stands we have to put the component in a modal due to the limitations of the method.

HilSny avatar Jul 07 '25 17:07 HilSny

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

RCGitBot avatar Jul 07 '25 17:07 RCGitBot

I believe it is the modal component I have that is causing the issue but this makes the sdk pretty limited. Would y'all ever add the callbacks to the presentPaywall method? Overall I think the paywall ui component and method should have parity in that respect.

HilSny avatar Jul 07 '25 18:07 HilSny

Hello @HilSny

Thanks for reporting the issue. I've been able to reproduce just by wrapping the Paywall view in a Modal component:

<Modal>
    <RevenueCatUI.Paywall/>
</Modal>

And I totally agree the presentPaywall function should provide the same callbacks as the Paywall view component.

As a temporary workaround while we fix this issue, if your app uses react-navigation, you could try to use their modal functionality:

https://reactnavigation.org/docs/modal

MarkVillacampa avatar Jul 08 '25 11:07 MarkVillacampa

Awesome, that would be so great. I actually like how the modal presents better with presentPaywall but don't want to use it without the callbacks. As for react-navigation, that works great! Thanks for the suggestions.

HilSny avatar Jul 08 '25 16:07 HilSny

Reopening issue. It was closed due to a failing automation. Sorry about that.

vegaro avatar Sep 22 '25 07:09 vegaro