RevenueCat / purchases-ios

In-app purchases and subscriptions made easy. Support for iOS, watchOS, tvOS, macOS, and visionOS.
https://www.revenuecat.com/
MIT License
2.19k stars 293 forks source link

`Xcode 16` / `iOS 18`: Thread 21: EXC_BAD_ACCESS (code=1, address=0xfffffffffffffff8) in ETagManager.Response.encode(to:) #3949

Open eklipse2k8 opened 3 weeks ago

eklipse2k8 commented 3 weeks ago

Describe the bug When attempting to initialize the latest SDK, I am getting an EXC_BAD_ACCESS in the call to ETagManager.Response.encode(to:)

  1. Environment

    1. Platform: iOS
    2. SDK version: iOS 18.0
    3. StoreKit version:
      • [x] StoreKit 1
      • [ ] StoreKit 2 (enabled with usesStoreKit2IfAvailable(true))
    4. OS version: iOS 17.4
    5. Xcode version: 16.0 (16A5171c)
    6. Device and/or simulator:
      • [X] Device
      • [X] Simulator
    7. Environment:
      • [X] Sandbox
      • [X] TestFight
      • [X] 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.

#0  0x000000010b918764 in ETagManager.Response.encode(to:) ()
#1  0x000000010b919278 in protocol witness for Encodable.encode(to:) in conformance ETagManager.Response ()
#2  0x00000001932394bc in dispatch thunk of Encodable.encode(to:) ()
#3  0x00000001808e05e4 in specialized closure #1 in __JSONEncoder.wrapGeneric<τ_0_0, τ_0_1>(_:for:_:) ()
#4  0x00000001808e3a3c in partial apply for specialized closure #1 in __JSONEncoder.wrapGeneric<τ_0_0, τ_0_1>(_:for:_:) ()
#5  0x00000001808e07c4 in specialized __JSONEncoder._wrapGeneric<τ_0_0>(_:for:_:) ()
#6  0x00000001808d48d0 in specialized __JSONEncoder.wrapGeneric<τ_0_0, τ_0_1>(_:for:_:) ()
#7  0x00000001808d3c7c in JSONEncoder.encode<τ_0_0>(_:) ()
#8  0x00000001808e241c in dispatch thunk of JSONEncoder.encode<τ_0_0>(_:) ()
#9  0x000000010b877548 in Encodable.jsonEncodedData.getter at /Users/mjarjoura/Library/Developer/Xcode/DerivedData/TourneyMate-exotvrxgrgtkbiajkvsrpzmrplci/SourcePackages/checkouts/purchases-ios/Sources/LocalReceiptParsing/DataConverters/Codable+Extensions.swift:46
#10 0x000000010b916988 in ETagManager.Response.asData() at /Users/mjarjoura/Library/Developer/Xcode/DerivedData/TourneyMate-exotvrxgrgtkbiajkvsrpzmrplci/SourcePackages/checkouts/purchases-ios/Sources/Networking/HTTPClient/ETagManager.swift:250
#11 0x000000010b9151a0 in ETagManager.storeIfPossible(_:for:) at /Users/mjarjoura/Library/Developer/Xcode/DerivedData/TourneyMate-exotvrxgrgtkbiajkvsrpzmrplci/SourcePackages/checkouts/purchases-ios/Sources/Networking/HTTPClient/ETagManager.swift:189
#12 0x000000010b915a70 in ETagManager.storeStatusCodeAndResponseIfNoError(for:response:eTag:) at /Users/mjarjoura/Library/Developer/Xcode/DerivedData/TourneyMate-exotvrxgrgtkbiajkvsrpzmrplci/SourcePackages/checkouts/purchases-ios/Sources/Networking/HTTPClient/ETagManager.swift:172
#13 0x000000010b914e54 in ETagManager.httpResultFromCacheOrBackend(with:request:retried:) at /Users/mjarjoura/Library/Developer/Xcode/DerivedData/TourneyMate-exotvrxgrgtkbiajkvsrpzmrplci/SourcePackages/checkouts/purchases-ios/Sources/Networking/HTTPClient/ETagManager.swift:111
#14 0x000000010b927cc0 in closure #2 in HTTPClient.createVerifiedResponse(request:urlRequest:data:response:requestStartTime:) at /Users/mjarjoura/Library/Developer/Xcode/DerivedData/TourneyMate-exotvrxgrgtkbiajkvsrpzmrplci/SourcePackages/checkouts/purchases-ios/Sources/Networking/HTTPClient/HTTPClient.swift:365
#15 0x000000010b85aa14 in Result.map<τ_0_0>(_:) ()
#16 0x000000010b927588 in HTTPClient.createVerifiedResponse(request:urlRequest:data:response:requestStartTime:) at /Users/mjarjoura/Library/Developer/Xcode/DerivedData/TourneyMate-exotvrxgrgtkbiajkvsrpzmrplci/SourcePackages/checkouts/purchases-ios/Sources/Networking/HTTPClient/HTTPClient.swift:364
#17 0x000000010b926b5c in HTTPClient.parse(urlResponse:request:urlRequest:data:error:requestStartTime:) at /Users/mjarjoura/Library/Developer/Xcode/DerivedData/TourneyMate-exotvrxgrgtkbiajkvsrpzmrplci/SourcePackages/checkouts/purchases-ios/Sources/Networking/HTTPClient/HTTPClient.swift:321
#18 0x000000010b928b54 in HTTPClient.handle(urlResponse:request:urlRequest:data:error:requestStartTime:) at /Users/mjarjoura/Library/Developer/Xcode/DerivedData/TourneyMate-exotvrxgrgtkbiajkvsrpzmrplci/SourcePackages/checkouts/purchases-ios/Sources/Networking/HTTPClient/HTTPClient.swift:405
#19 0x000000010b92ad10 in closure #1 in HTTPClient.start(request:) at /Users/mjarjoura/Library/Developer/Xcode/DerivedData/TourneyMate-exotvrxgrgtkbiajkvsrpzmrplci/SourcePackages/checkouts/purchases-ios/Sources/Networking/HTTPClient/HTTPClient.swift:492
#20 0x000000010b92ae38 in thunk for @escaping @callee_guaranteed @Sendable (@guaranteed Data?, @guaranteed NSURLResponse?, @guaranteed Error?) -> () ()
#21 0x000000018433078c in ___lldb_unnamed_symbol2675 ()
#22 0x000000018434c59c in ___lldb_unnamed_symbol3274 ()
#23 0x0000000180170104 in _dispatch_call_block_and_release ()
#24 0x0000000180171978 in _dispatch_client_callout ()
#25 0x0000000180179b10 in _dispatch_lane_serial_drain ()
#26 0x000000018017a688 in _dispatch_lane_invoke ()
#27 0x0000000180185a84 in _dispatch_root_queue_drain_deferred_wlh ()
#28 0x00000001801850d0 in _dispatch_workloop_worker_thread ()
#29 0x0000000104d5b814 in _pthread_wqthread ()
  1. Steps to reproduce, with a description of expected vs. actual behavior

This is happening during app launch, so not much I can do.

  1. Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)
DEBUG: ℹ️ Configuring SDK using RevenueCat's UserDefaults suite.
DEBUG: 👤 Identifying App User ID
DEBUG: ℹ️ Debug logging enabled
DEBUG: ℹ️ SDK Version - 4.43.0
DEBUG: ℹ️ Bundle ID - com.barkingloudly.snapdecks
DEBUG: ℹ️ System Version - Version 17.4 (Build 21E213)
DEBUG: ℹ️ Using a simulator. Ensure you have a StoreKit Config file set up before trying to fetch products or make purchases.
See https://errors.rev.cat/testing-in-simulator for more details.
DEBUG: 👤 No initial App User ID
DEBUG: ℹ️ Purchases is configured with response verification disabled
  1. Additional context
RCGitBot commented 3 weeks ago

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

fishandphil commented 3 weeks ago

I believe that we're getting a similar crash at launch with Xcode 16 beta.

Screenshot 2024-06-11 at 07 57 56
MarkVillacampa commented 3 weeks ago

Hey @fishandphil @eklipse2k8 thanks for your reports!

We're aware of this issue and already filed FB13828346 with Apple.

The issue seems to manifest only when compiling with Xcode 16, and running on iOS 17/macOS 14.

We're trying to find a workaround while Apple gets back to us. We'll keep you posted.

Meanwhile, you can test your apps by running on an iOS 18 simulator or device.

Sorry for the inconvenience!

YiLee01 commented 2 weeks ago

The same issue also appears on devices running iOS 15.

MarkVillacampa commented 2 weeks ago

Filed an issue in the Swift repo:

https://github.com/apple/swift/issues/74333

xAstralMars commented 2 weeks ago

got the same issue with both iOS 18 beta and iOS 17.4. seems like it doesn't point to the code that crashed on 18.0 beta, only on the iOS 17 emulator

mos-stuartpatt commented 1 week ago

Is there a known version of the SDK that we know isn't having this issue? Seeing this on 17.4 also

xAstralMars commented 1 week ago

Is there a known version of the SDK that we know isn't having this issue? Seeing this on 17.4 also

it's on anything prior to ios 18 beta on Xcode 16 beta. the only version that works is ios 18

roddymunro commented 1 week ago

Confirming that this is still an issue on Xcode 16 beta 2.

Melber17 commented 6 days ago

The same

image
ekurutepe commented 4 days ago

Are there any plans for a workaround, just in case the Swift bug is not fixed swiftly enough?

Edit: it seems like it's fixed already https://github.com/swiftlang/swift/issues/74333#issuecomment-2195013992

VatanaChhorn commented 3 days ago

Installed release/6.0 (June 22, 2024), and the crashes are still there.