Swift thread continuation crash when calling isEligibleForAgeFeatures

Hi,

We’ve been observing crashes when calling “try await DeclaredAgeRange.AgeRangeService.shared.isEligibleForAgeFeatures”.

Our crash logs show a “suspend resume partial function” crash from libswift_Concurrency.dylib swift::runJobInEstablishedExecutorContext.

Based on our analysis, this is because once Apple’s eligibility check completes, it attempts to resume the Swift task continuation directly on its own internal background thread instead of yielding back to the Swift cooperative thread pool. Because the caller task inherits @MainActor isolation (due to a UIViewController being passed into our pipeline further up as it’s needed for requestAgeRange), the Swift runtime crashes when trying to reconcile the @MainActor context on Apple's foreign background thread.

Has anyone encountered this and found a fix, and is this a known issue?

Thanks!

Thank you for the post. I have tried that API and I do not see any crash, however I’m very interested in seeing where it crashes for you. May I ask you to provide the Xcode you are using, macOS, iOS (simulator or physical device) as well as the focused sample code to reproduce it and the crash file?

To view the version of Xcode, select Xcode > About Xcode.

do {
    let response = try await AgeRangeService.shared.isEligibleForAgeFeatures
    // Handle response
    if response {
        logger.info("Eligible for age features.")
    } else {
        logger.info( "Not eligible for age features.")
    }              
} catch {
     logger.error("Fail to check eligibility for age features.")
}

Sandbox https://developer.apple.com/documentation/storekit/testing-age-assurance-in-sandbox

A focused Xcode project that builds and demonstrates the issue. Ideally this will be a new Xcode project created specifically to demonstrate this issue, and which includes only the minimal code and API necessary to reproduce the issue. This focuses on the important code paths and may require you to perform additional debugging to extract the relevant code. Please do not include any 3rd-party code or frameworks unless they are absolutely required for this targeted test project to run.

Posting a Crash Report. https://developer.apple.com/forums/thread/688669

Looking forward to your reply.

Albert  WWDR

Swift thread continuation crash when calling isEligibleForAgeFeatures
 
 
Q