RevenueCat / purchases-android

Android in-app purchases and subscriptions made easy.
https://www.revenuecat.com/
MIT License
253 stars 52 forks source link

Crash in 7.3.5 #1566

Closed zenyagami closed 8 months ago

zenyagami commented 9 months ago

Describe the bug There is a crash in some devices, apparently in Tablets Context android.app.ContextImpl@61fd4b4 is not a UiContext I found that is in this code val metrics = WindowMetricsCalculator.getOrCreate().computeCurrentWindowMetrics(context) apparently computeCurrentWindowMetrics need to be "UI context" and seems that is not always the case here is a stack trace

Fatal Exception: java.lang.IllegalArgumentException: Context android.app.ContextImpl@61fd4b4 is not a UiContext
       at androidx.window.layout.util.ContextUtils.unwrapUiContext$window_release(ContextUtils.kt:52)
       at androidx.window.layout.WindowMetricsCalculatorCompat.computeCurrentWindowMetrics(WindowMetricsCalculatorCompat.kt:67)
       at com.revenuecat.purchases.ui.revenuecatui.helpers.WindowHelperKt.getScreenSize(WindowHelper.kt:69)
       at com.revenuecat.purchases.ui.revenuecatui.helpers.WindowHelperKt.windowSizeClass(WindowHelper.kt:55)
       at com.revenuecat.purchases.ui.revenuecatui.helpers.WindowHelperKt.computeWindowHeightSizeClass(WindowHelper.kt:25)
       at com.revenuecat.purchases.ui.revenuecatui.helpers.WindowHelperKt.shouldUseLandscapeLayout(WindowHelper.kt:44)
       at com.revenuecat.purchases.ui.revenuecatui.helpers.WindowHelperKt.shouldUseLandscapeLayout(WindowHelper.kt:38)
       at com.revenuecat.purchases.ui.revenuecatui.templates.Template5Kt.Template5(Template5.kt:100)
       at com.revenuecat.purchases.ui.revenuecatui.InternalPaywallKt.TemplatePaywall(InternalPaywall.kt:155)
       at com.revenuecat.purchases.ui.revenuecatui.InternalPaywallKt.access$TemplatePaywall(InternalPaywall.kt:1)
       at com.revenuecat.purchases.ui.revenuecatui.InternalPaywallKt$LoadedPaywall$3$1.invoke(InternalPaywall.kt:138)
       at com.revenuecat.purchases.ui.revenuecatui.InternalPaywallKt$LoadedPaywall$3$1.invoke(InternalPaywall.kt:137)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
       at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
       at com.revenuecat.purchases.ui.revenuecatui.InternalPaywallKt.LoadedPaywall(InternalPaywall.kt:133)
       at com.revenuecat.purchases.ui.revenuecatui.InternalPaywallKt.access$TemplatePaywall(InternalPaywall.kt:1)
       at com.revenuecat.purchases.ui.revenuecatui.InternalPaywallKt.access$LoadedPaywall(InternalPaywall.kt:1)
       at com.revenuecat.purchases.ui.revenuecatui.InternalPaywallKt$InternalPaywall$2$2.invoke(InternalPaywall.kt:84)
       at com.revenuecat.purchases.ui.revenuecatui.InternalPaywallKt$InternalPaywall$2$2.invoke(InternalPaywall.kt:83)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:117)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
       at androidx.compose.animation.AnimatedVisibilityKt.AnimatedEnterExitImpl(AnimatedVisibility.kt:818)
       at androidx.compose.animation.AnimatedVisibilityKt.AnimatedVisibilityImpl(AnimatedVisibility.kt:741)
       at androidx.compose.animation.AnimatedVisibilityKt.AnimatedVisibility(AnimatedVisibility.kt:135)
       at com.revenuecat.purchases.ui.revenuecatui.InternalPaywallKt$InternalPaywall$2.invoke(InternalPaywall.kt:79)
       at com.revenuecat.purchases.ui.revenuecatui.InternalPaywallKt$InternalPaywall$2.invoke(InternalPaywall.kt:61)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
       at com.revenuecat.purchases.ui.revenuecatui.fonts.PaywallThemeKt.PaywallTheme(PaywallTheme.kt:15)
       at com.revenuecat.purchases.ui.revenuecatui.InternalPaywallKt.InternalPaywall(InternalPaywall.kt:61)
       at com.revenuecat.purchases.ui.revenuecatui.PaywallKt.Paywall(Paywall.kt:12)
       at app.ui.main.inappbilling.PremiumPaywallFragment$onCreateView$1$1$1$2.invoke(PremiumPaywallFragment.kt:122)
       at app.ui.main.inappbilling.PremiumPaywallFragment$onCreateView$1$1$1$2.invoke(PremiumPaywallFragment.kt:97)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:117)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
       at androidx.compose.material3.ScaffoldKt$ScaffoldLayout$1$1$1$bodyContentPlaceables$1.invoke(Scaffold.kt:239)
       at androidx.compose.material3.ScaffoldKt$ScaffoldLayout$1$1$1$bodyContentPlaceables$1.invoke(Scaffold.kt:221)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
       at androidx.compose.runtime.ComposablesKt.ReusableContentHost(Composables.kt:172)
       at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$subcompose$3$1$1.invoke(SubcomposeLayout.kt:477)
       at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$subcompose$3$1$1.invoke(SubcomposeLayout.kt:476)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
       at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
       at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:93)
       at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3269)
       at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3202)
       at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:722)
       at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:1059)
       at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:3566)
       at androidx.compose.runtime.CompositionImpl.composeInitial(Composition.kt:630)
       at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:620)
       at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcomposeInto(SubcomposeLayout.kt:498)
       at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:471)
       at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:462)
       at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:446)
       at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$Scope.subcompose(SubcomposeLayout.kt:862)
       at androidx.compose.material3.ScaffoldKt$ScaffoldLayout$1$1$1.invoke(Scaffold.kt:221)
       at androidx.compose.material3.ScaffoldKt$ScaffoldLayout$1$1$1.invoke(Scaffold.kt:128)
       at androidx.compose.ui.layout.Placeable$PlacementScope$Companion.executeWithRtlMirroringValues(Placeable.java:385)
       at androidx.compose.ui.layout.MeasureScope$layout$1.placeChildren(MeasureScope.kt:52)
       at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$createMeasurePolicy$1$measure-3p2s80s$$inlined$createMeasureResult$2.placeChildren(SubcomposeLayout.kt:951)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate$layoutChildrenBlock$1.invoke(LayoutNodeLayoutDelegate.kt:364)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate$layoutChildrenBlock$1.invoke(LayoutNodeLayoutDelegate.kt:359)
       at androidx.compose.runtime.snapshots.Snapshot.enter(Snapshot.java:131)
       at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:476)
       at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:496)
       at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256)
       at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
       at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutSnapshotReads$ui_release(OwnerSnapshotObserver.kt:83)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.layoutChildren(LayoutNodeLayoutDelegate.kt:392)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.onNodePlaced$ui_release(LayoutNodeLayoutDelegate.kt:548)
       at androidx.compose.ui.node.InnerNodeCoordinator.placeAt-f8xVGno(InnerNodeCoordinator.kt:160)
       at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:34)
       at androidx.compose.ui.layout.Placeable$PlacementScope.placeApparentToRealOffset-aW-9-wM$ui_release(Placeable.kt:349)
       at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50(Placeable.kt:232)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate$placeOuterCoordinatorBlock$1.invoke(LayoutNodeLayoutDelegate.kt:486)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate$placeOuterCoordinatorBlock$1.invoke(LayoutNodeLayoutDelegate.kt:482)
       at androidx.compose.runtime.snapshots.Snapshot.enter(Snapshot.java:131)
       at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:476)
       at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:496)
       at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256)
       at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
       at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutModifierSnapshotReads$ui_release(OwnerSnapshotObserver.kt:98)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.placeOuterCoordinator-f8xVGno(LayoutNodeLayoutDelegate.kt:740)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.placeAt-f8xVGno(LayoutNodeLayoutDelegate.kt:714)
       at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:34)
       at androidx.compose.ui.layout.Placeable$PlacementScope.placeApparentToRealOffset-aW-9-wM$ui_release(Placeable.kt:349)
       at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50(Placeable.kt:232)
       at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50$default(Placeable.kt:231)
       at androidx.compose.foundation.layout.BoxKt.placeInBox(Box.kt:185)
       at androidx.compose.foundation.layout.BoxKt.access$placeInBox(Box.kt:1)
       at androidx.compose.foundation.layout.BoxKt$boxMeasurePolicy$1$2.invoke(Box.kt:125)
       at androidx.compose.foundation.layout.BoxKt$boxMeasurePolicy$1$2.invoke(Box.kt:124)
       at androidx.compose.ui.layout.Placeable$PlacementScope$Companion.executeWithRtlMirroringValues(Placeable.java:385)
       at androidx.compose.ui.layout.MeasureScope$layout$1.placeChildren(MeasureScope.kt:52)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate$layoutChildrenBlock$1.invoke(LayoutNodeLayoutDelegate.kt:364)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate$layoutChildrenBlock$1.invoke(LayoutNodeLayoutDelegate.kt:359)
       at androidx.compose.runtime.snapshots.Snapshot.enter(Snapshot.java:131)
       at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:476)
       at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:496)
       at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256)
       at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
       at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutSnapshotReads$ui_release(OwnerSnapshotObserver.kt:83)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.layoutChildren(LayoutNodeLayoutDelegate.kt:392)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.onNodePlaced$ui_release(LayoutNodeLayoutDelegate.kt:548)
       at androidx.compose.ui.node.InnerNodeCoordinator.placeAt-f8xVGno(InnerNodeCoordinator.kt:160)
       at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:34)
       at androidx.compose.ui.layout.Placeable$PlacementScope.placeApparentToRealOffset-aW-9-wM$ui_release(Placeable.kt:349)
       at androidx.compose.ui.layout.Placeable$PlacementScope.placeWithLayer(Placeable.kt:304)
       at androidx.compose.ui.layout.Placeable$PlacementScope.placeWithLayer$default(Placeable.kt:299)
       at androidx.compose.ui.graphics.SimpleGraphicsLayerModifier$measure$1.invoke(GraphicsLayerModifier.kt:648)
       at androidx.compose.ui.graphics.SimpleGraphicsLayerModifier$measure$1.invoke(GraphicsLayerModifier.kt:647)
       at androidx.compose.ui.layout.Placeable$PlacementScope$Companion.executeWithRtlMirroringValues(Placeable.java:385)
       at androidx.compose.ui.layout.MeasureScope$layout$1.placeChildren(MeasureScope.kt:52)
       at androidx.compose.ui.node.LayoutModifierNodeCoordinator.placeAt-f8xVGno(LayoutModifierNodeCoordinator.kt:172)
       at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:34)
       at androidx.compose.ui.layout.Placeable$PlacementScope.placeApparentToRealOffset-aW-9-wM$ui_release(Placeable.kt:349)
       at androidx.compose.ui.layout.Placeable$PlacementScope.placeWithLayer-aW-9-wM(Placeable.kt:324)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate$placeOuterCoordinatorBlock$1.invoke(LayoutNodeLayoutDelegate.kt:491)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate$placeOuterCoordinatorBlock$1.invoke(LayoutNodeLayoutDelegate.kt:482)
       at androidx.compose.runtime.snapshots.Snapshot.enter(Snapshot.java:131)
       at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:476)
       at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:496)
       at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256)
       at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
       at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutModifierSnapshotReads$ui_release(OwnerSnapshotObserver.kt:98)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.placeOuterCoordinator-f8xVGno(LayoutNodeLayoutDelegate.kt:740)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.placeAt-f8xVGno(LayoutNodeLayoutDelegate.kt:714)
       at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:34)
       at androidx.compose.ui.layout.Placeable$PlacementScope.placeApparentToRealOffset-aW-9-wM$ui_release(Placeable.kt:349)
       at androidx.compose.ui.layout.Placeable$PlacementScope.placeRelativeWithLayer(Placeable.kt:282)
       at androidx.compose.ui.layout.Placeable$PlacementScope.placeRelativeWithLayer$default(Placeable.kt:277)
       at androidx.compose.ui.layout.RootMeasurePolicy$measure$2.invoke(RootMeasurePolicy.kt:43)
       at androidx.compose.ui.layout.RootMeasurePolicy$measure$2.invoke(RootMeasurePolicy.kt:39)
       at androidx.compose.ui.layout.Placeable$PlacementScope$Companion.executeWithRtlMirroringValues(Placeable.java:385)
       at androidx.compose.ui.layout.MeasureScope$layout$1.placeChildren(MeasureScope.kt:52)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate$layoutChildrenBlock$1.invoke(LayoutNodeLayoutDelegate.kt:364)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate$layoutChildrenBlock$1.invoke(LayoutNodeLayoutDelegate.kt:359)
       at androidx.compose.runtime.snapshots.Snapshot.enter(Snapshot.java:131)
       at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:476)
       at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:496)
       at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256)
       at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
       at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutSnapshotReads$ui_release(OwnerSnapshotObserver.kt:83)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.layoutChildren(LayoutNodeLayoutDelegate.kt:392)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.onNodePlaced$ui_release(LayoutNodeLayoutDelegate.kt:548)
       at androidx.compose.ui.node.InnerNodeCoordinator.placeAt-f8xVGno(InnerNodeCoordinator.kt:160)
       at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:34)
       at androidx.compose.ui.layout.Placeable$PlacementScope.placeApparentToRealOffset-aW-9-wM$ui_release(Placeable.kt:349)
       at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50(Placeable.kt:232)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate$placeOuterCoordinatorBlock$1.invoke(LayoutNodeLayoutDelegate.kt:486)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate$placeOuterCoordinatorBlock$1.invoke(LayoutNodeLayoutDelegate.kt:482)
       at androidx.compose.runtime.snapshots.Snapshot.enter(Snapshot.java:131)
       at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:476)
       at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:496)
       at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256)
       at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
       at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutModifierSnapshotReads$ui_release(OwnerSnapshotObserver.kt:98)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.placeOuterCoordinator-f8xVGno(LayoutNodeLayoutDelegate.kt:740)
       at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.placeAt-f8xVGno(LayoutNodeLayoutDelegate.kt:714)
       at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:34)
       at androidx.compose.ui.layout.Placeable$PlacementScope.placeApparentToRealOffset-aW-9-wM$ui_release(Placeable.kt:349)
       at androidx.compose.ui.layout.Placeable$PlacementScope.placeRelative(Placeable.kt:205)
       at androidx.compose.ui.layout.Placeable$PlacementScope.placeRelative$default(Placeable.kt:204)
       at androidx.compose.ui.node.LayoutNode.place$ui_release(LayoutNode.kt:903)
       at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureAndRelayoutIfNeeded(MeasureAndLayoutDelegate.kt:493)
       at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureAndRelayoutIfNeeded$default(MeasureAndLayoutDelegate.kt:461)
       at androidx.compose.ui.node.MeasureAndLayoutDelegate.measureAndLayout(MeasureAndLayoutDelegate.kt:354)
       at androidx.compose.ui.platform.AndroidComposeView.onLayout(AndroidComposeView.android.kt:1063)
       at android.view.View.layout(View.java:19856)
       at android.view.ViewGroup.layout(ViewGroup.java:6159)
       at androidx.compose.ui.platform.AbstractComposeView.internalOnLayout$ui_release(ComposeView.android.kt:322)
       at androidx.compose.ui.platform.AbstractComposeView.onLayout(ComposeView.android.kt:313)
       at android.view.View.layout(View.java:19856)
       at android.view.ViewGroup.layout(ViewGroup.java:6159)
       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
       at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
       at android.view.View.layout(View.java:19856)
       at android.view.ViewGroup.layout(ViewGroup.java:6159)
       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
       at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
       at android.view.View.layout(View.java:19856)
       at android.view.ViewGroup.layout(ViewGroup.java:6159)
       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
       at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
       at android.view.View.layout(View.java:19856)
       at android.view.ViewGroup.layout(ViewGroup.java:6159)
       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
       at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
       at android.view.View.layout(View.java:19856)
       at android.view.ViewGroup.layout(ViewGroup.java:6159)
       at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
       at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
       at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
       at android.view.View.layout(View.java:19856)
       at android.view.ViewGroup.layout(ViewGroup.java:6159)
       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
       at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
       at android.view.View.layout(View.java:19856)
       at android.view.ViewGroup.layout(ViewGroup.java:6159)
       at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
       at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
       at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
       at android.view.View.layout(View.java:19856)
       at android.view.ViewGroup.layout(ViewGroup.java:6159)
       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
       at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
       at com.android.internal.policy.DecorView.onLayout(DecorView.java:762)
       at android.view.View.layout(View.java:19856)
       at android.view.ViewGroup.layout(ViewGroup.java:6159)
       at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2597)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2302)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1438)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6982)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:916)
       at android.view.Choreographer.doCallbacks(Choreographer.java:728)
       at android.view.Choreographer.doFrame(Choreographer.java:660)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:902)
       at android.os.Handler.handleCallback(Handler.java:790)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6523)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:940)
  1. Environment
    1. Platform: Android
    2. SDK version: 7.3.5
    3. OS version: Android 8 to 12
    4. Android Studio version: Android Studio Jellyfish | 2023.3.1 Canary
    5. How widespread is the issue. Percentage of devices affected. 8% so far
  2. Debug logs that reproduce the issue

Additional context Add any other context about the problem here.

RCGitBot commented 9 months ago

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

tonidero commented 9 months ago

Hi @zenyagami, thanks for reporting! We're taking a look but we haven't been able to repro yet. A few questions to help us debug this:

It might be related to this change but we're not sure yet since we aren't able to repro.

zenyagami commented 9 months ago

Hi @zenyagami, thanks for reporting! We're taking a look but we haven't been able to repro yet. A few questions to help us debug this:

  • Seems that you're using the Paywall composable inside a fragment correct?
  • Could you share a snippet of code on how you're creating/displaying the paywall?
  • Are you able to reproduce yourself?
  • Is this the first version where you've implemented paywalls or did you have them before? If so, did you have the crash before?

It might be related to this change but we're not sure yet since we aren't able to repro.

I reproduced in a Realme 5i, and I saw devices like:

CPH1909, K2501, Model:Sp7731e_1h10_native, QUAD-CORE T3 P1, YT9213AJ,Vivo 1916 which are basically a headunit/tablets from china, that being said is related to the change in 1551, what I can see , the issue is in getScreenSize from your helper class WindowHelperKt and the issue is in computeCurrentWindowMetricswhich expects UI context (no idea why). perhaps worth using something like

val windowSize = calculateWindowSizeClass(requireActivity()) // you can get the activity in compose as well

and yes I'm using a paywall in a fragment, it was not happening before, this is new this is my code

AppTheme {
                val windowSize = calculateWindowSizeClass(requireActivity())
                Scaffold(
                    topBar = {
                        TopAppBar(
                            title = {
                                Text(
                                    stringResource(id = AZ.string.premium_choose_title),
                                    overflow = TextOverflow.Ellipsis
                                )
                            },
                            navigationIcon = {
                                IconButton(onClick = { onNavigationClicked() }) {
                                    Icon(
                                        imageVector = Icons.Filled.ArrowBack,
                                        contentDescription = stringResource(id = R.string.common_done)
                                    )
                                }
                            },
                            actions = {
                                IconButton(onClick = { launchGoogleHelp() }) {
                                    Icon(
                                        imageVector = Icons.Filled.ManageAccounts,
                                        contentDescription = null,
                                    )
                                }
                            }
                        )
                    }
                ) { paddingValues ->
                    Box(
                        modifier = Modifier
                            .fillMaxSize()
                            .padding(paddingValues)
                    ) {
                        val options = PaywallOptions.Builder(
                            dismissRequest = {
                                onNavigationClicked()
                            },
                        ).setListener(object : PaywallListener {
                            override fun onPurchaseCompleted(
                                customerInfo: CustomerInfo,
                                storeTransaction: StoreTransaction
                            ) {
                                viewModel.onPurchaseCompleted(customerInfo)
                                onSuccessPurchase()
                            }

                            override fun onRestoreCompleted(customerInfo: CustomerInfo) {
                                viewModel.onPurchaseCompleted(customerInfo)
                                onRestored()
                            }
                        }).build()
                       // this is my workaround for the paywall, I'm forcing to use portrait but for some reason,
                      // some tablets the portrait mode is like landscape, so I used this in the mean time until RC implements the 
                     // the landscape which is here I think https://github.com/RevenueCat/purchases-android/pull/1551
                        if (windowSize.heightSizeClass == WindowHeightSizeClass.Compact) {
                            PaywallFooter(options = options)
                        } else {
                            Paywall(
                                options = options
                            )
                        }
                    }
                }
            }
tonidero commented 9 months ago

Hi @zenyagami, I've been investigating and it seems when using StrictMode, it's possible this error might be triggered (Currently trying to repro). Is it possible you have StrictMode enabled?

As for getting the activity, we currently use LocalContext.current which may not be an UI context. We don't have direct access to the activity from the library right now. We could try to obtain it like this: https://stackoverflow.com/a/67927037 but that also had some issues from our tests, so we're studying our options.

zenyagami commented 9 months ago

Hi @zenyagami, I've been investigating and it seems when using StrictMode, it's possible this error might be triggered (Currently trying to repro). Is it possible you have StrictMode enabled?

As for getting the activity, we currently use LocalContext.current which may not be an UI context. We don't have direct access to the activity from the library right now. We could try to obtain it like this: https://stackoverflow.com/a/67927037 but that also had some issues from our tests, so we're studying our options.

I dont have StrictMode explicitly enabled, and seems it does not hapens in all devices tho, the other alternative is that we send the windowSize already as param, the SO is using app Compat, maybe you can try how Google was getting it

/**
 * Find the closest Activity in a given Context.
 */
internal fun Context.findActivity(): Activity {
    var context = this
    while (context is ContextWrapper) {
        if (context is Activity) return context
        context = context.baseContext
    }
    throw IllegalStateException("Permissions should be called in the context of an Activity")
}

This is from the accompanist and similar to the one in StackOverflow Here

tonidero commented 9 months ago

Hi @zenyagami, we've just released version 7.4.0 with a fix we hope it might solve your problem: https://github.com/RevenueCat/purchases-android/pull/1570. Do you mind giving it a try?

furkanuzun commented 9 months ago

Hi @zenyagami, we've just released version 7.4.0 with a fix we hope it might solve your problem: #1570. Do you mind giving it a try?

I have this error on react-native-purchase. When i look logcat i saw this error. "java.lang.IllegalArgumentException: Context android.app.ContextImpl@c4a1430 is not a UiContext" Have you any feedback about that? And if released android version was solution when this available for react native package?

tonidero commented 8 months ago

Hi @furkanuzun, we just released a new version of the react native SDK with this fix: 7.17.1. Do you mind giving it a try and see if the issue still happens? Thanks for reporting this!

furkanuzun commented 8 months ago

Hi @furkanuzun, we just released a new version of the react native SDK with this fix: 7.17.1. Do you mind giving it a try and see if the issue still happens? Thanks for reporting this!

Hi @tonidero, problem was solved in 7.17.1 version. Thanks!

tonidero commented 8 months ago

Thanks @furkanuzun! Considering we already have reports of this being fixed, going to close this tentatively. If there are more issues we can reopen. Thanks again for reporting!

github-actions[bot] commented 8 months ago

This issue has been automatically locked due to no recent activity after it was closed. Please open a new issue for related reports.