RevenueCat/purchases-ios

iOS 18 Beta 5 SwiftUICore/GraphHost.swift:215: Fatal error: no current graph host

Closed this issue · 10 comments

Describe the bug
I am receiving this weird crash after launching the app while showing the paywall. It happens right after the paywall is seen.

  1. Environment
    1. Platform: iOS
    2. SDK version: (main branch from spm, commit: 348258a
    3. StoreKit version:
      • [] StoreKit 1
      • StoreKit 2 (enabled with usesStoreKit2IfAvailable(true))
    4. OS version: 18 Beta 5
    5. Xcode version: Xcode 15.4, Xcode 16 Beta 4, Beta 5
    6. Device and/or simulator:
      • Device
      • Simulator
    7. Environment:
      • Sandbox
      • TestFlight
      • [] Production
    8. How widespread is the issue. Percentage of devices affected.
  2. Debug logs that reproduce the issue. Complete logs with Purchases.logLevel = .verbose will help us debug this issue.

Console prints this:
SwiftUICore/GraphHost.swift:215: Fatal error: no current graph host
Xcode says this:

PressReaderStaging`static PressReaderApp.$main():
    0x100269614 <+0>:  stp    x20, x19, [sp, #-0x20]!
    0x100269618 <+4>:  stp    x29, x30, [sp, #0x10]
    0x10026961c <+8>:  add    x29, sp, #0x10
    0x100269620 <+12>: mov    x0, #0x0
    0x100269624 <+16>: bl     0x1002676ac               ; type metadata accessor for PressReaderStaging.PressReaderApp at <compiler-generated>
    0x100269628 <+20>: mov    x20, x0
    0x10026962c <+24>: bl     0x100269648               ; lazy protocol witness table accessor for type PressReaderStaging.PressReaderApp and conformance PressReaderStaging.PressReaderApp : SwiftUI.App in PressReaderStaging at <compiler-generated>
    0x100269630 <+28>: mov    x1, x0
    0x100269634 <+32>: mov    x0, x20
    0x100269638 <+36>: bl     0x1013ce4fc               ; symbol stub for: static SwiftUI.App.main() -> ()
->  0x10026963c <+40>: ldp    x29, x30, [sp, #0x10]
    0x100269640 <+44>: ldp    x20, x19, [sp], #0x20
    0x100269644 <+48>: ret 

Verbose logs:

VERBOSE: DeviceCache.init: DeviceCache (0x0000000301391ce0)
VERBOSE: PurchasesOrchestrator.init: PurchasesOrchestrator (0x0000000105159a00)
DEBUG: ℹ️ Purchases is configured with response verification disabled
DEBUG: ℹ️ Purchases is configured with StoreKit version 2
VERBOSE: Purchases.init: created new Purchases instance: Purchases (0x0000000104010d00)
StoreKit Wrapper: right(<RevenueCat.PaymentQueueWrapper: 0x3038a0800>)
INFO: ℹ️ Purchases instance already set. Did you mean to configure two Purchases objects?
VERBOSE: DeviceCache.init: DeviceCache (0x00000003013bd3b0)
VERBOSE: PurchasesOrchestrator.init: PurchasesOrchestrator (0x00000001053da800)
DEBUG: ℹ️ Purchases is configured with response verification disabled
DEBUG: ℹ️ Purchases is configured with StoreKit version 2
VERBOSE: Purchases.init: created new Purchases instance: Purchases (0x0000000105242680)
StoreKit Wrapper: right(<RevenueCat.PaymentQueueWrapper: 0x3038e5d80>)
VERBOSE: Updating all caches
VERBOSE: Updating all caches
VERBOSE: Purchases.deinit: Purchases (0x0000000104010d00)
VERBOSE: PurchasesOrchestrator.deinit: PurchasesOrchestrator (0x0000000105159a00)
VERBOSE: PurchasesOrchestrator: caching presented paywall
  1. Steps to reproduce, with a description of expected vs. actual behavior
    I am presenting a sheet after launch my main view. Then I present paywall over this, the crash happens.

  2. Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)

  3. Additional context
    Crash probably happens here:
    RevenutCatUI>Modifiers>ViewExtensions. Line 110
    When I comment out ViewThatFits, it does not crash:

    /// Equivalent to `scrollableIfNecessary` except that it's always scrollable on iOS 15
    /// to work around issues with that iOS 15 implementation in some instances.
    @ViewBuilder
    func scrollableIfNecessaryWhenAvailable(_ axis: Axis = .vertical, enabled: Bool = true) -> some View {
        if enabled {
            if #available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *) {
//                ViewThatFits(in: axis.scrollViewAxis) {
//                    self

                    ScrollView(axis.scrollViewAxis) {
                        self
                    }
//                }
            } else {
                self
                    .centeredContent(axis)
                    .scrollable(if: enabled)
            }
        } else {
            self
        }
    }

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

Hello @rocxteady,

Thanks for filing this issue. Can you confirm which template you're trying to show?

We've been able to track this down as a bug in SwiftUI and filed a Feedback with Apple. Meanwhile we'll try to find ways to mitigate this issue.

Here's a very minimal example that reproduces the crash:

import SwiftUI

struct ContentView: View {
    @State var show = false
    var body: some View {
        VStack {
            Text("hello")
            ViewThatFits {
                VStack {
                    if show {
                        Text("\(show)")
                    } else {
                        Text("\(show)")
                            .transition(.opacity.animation(.default))
                    }
                }
                ScrollView {
                    Text("inside scrollview")
                }
            }
        }
        .onAppear {
            show = true
        }
    }
}

Thank you for the reply and the detailed information @MarkVillacampa . Thank you for the example as well and I am glad you already knew the issue. I run into this bug while using Template 7, you know with the multi tier one. I tried Template 1 and it didn't crash. Would you like me to try other templates too?

I'm also having this issue - I'm using Template 5

Thanks for reporting folks!

No problem. Keep up the great work! @aboedo

We've just released v5.2.3 of the SDK with a fix for this issue in iOS 18.

https://github.com/RevenueCat/purchases-ios/releases/tag/5.2.3

We hope the issue gets resolved in the next beta (or at least before iOS 18 final ships) and we can revert the workaround.

Thank you all for reporting the issue.

We've just released v5.2.3 of the SDK with a fix for this issue in iOS 18.

https://github.com/RevenueCat/purchases-ios/releases/tag/5.2.3

We hope the issue gets resolved in the next beta (or at least before iOS 18 final ships) and we can revert the workaround.

Thank you all for reporting the issue.

Hi Mark,

Can we also get this iOS version updated for React Native library as well? we have bunch of users experiencing the crash. And we need to update it as well. How long would it take for revenuecat react native library to get updated with this version?

The same crash happens on visionOS 2 beta 5

Hi everybody, the underlying SwiftUI bug that was causing this crash has been fixed in the latest iOS betas (iOS 18.1 beta 2 / iOS 18 beta 6). I’m tentatively closing this issue for now, but feel free to reopen if there’s something more we should dig into!