apple / swift-async-algorithms

Async Algorithms for Swift
Apache License 2.0
3.07k stars 151 forks source link

swift-async-algorithms 1.0.1 can no longer be built in Swift Playgrounds on iPadOS #316

Closed kkebo closed 5 months ago

kkebo commented 5 months ago

311 has broken apps depending on swift-async-algorithms on Swift Playgrounds on iPadOS.

IMG_0442

The reproducible example is here. Or, you can reproduce the issue by the following steps.

  1. Create a new app on Swift Playgrounds (iPadOS)
  2. Add a swift package
  3. Input https://github.com/apple/swift-async-algorithms to the "Package URL" field
  4. Press the return key

Then, the following error will be shown.

error message ``` Could not resolve package graph. Cannot continue. unknownError(PlaygroundExecution.ConsoleReadingExecutionOperation.OperationError.failed(PlaygroundExecution.ExecutionError.remoteProcessWasInterrupted, Optional(["ThreadInfoDictionaries": <__NSFrozenArrayM 0x307900540>( { DispatchQueueName = "com.apple.main-thread"; StackFrameDictionaries = ( { CrashAnnotationMessage = "PackageDescription/Context.swift:19: Fatal error: 'try!' expression unexpectedly raised an error: Could not decode ContextModel parameter.\n"; StackFrameModule = "libswiftCore.dylib"; StackFramePC = 6842454440; StackFrameSymbolName = "_$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF"; }, { CrashAnnotationMessage = "PackageDescription/Context.swift:19: Fatal error: 'try!' expression unexpectedly raised an error: Could not decode ContextModel parameter.\n"; StackFrameModule = "libswiftCore.dylib"; StackFramePC = 6842925296; StackFrameSymbolName = "_swift_unexpectedError"; }, { StackFrameModule = "libPackageDescription.dylib"; StackFramePC = 4465283188; StackFrameSymbolName = "_$s18PackageDescription7ContextV5model33_16EFAD36DA072BCD1C8EFF86E7A18833LL_WZ"; }, { StackFrameModule = "libdispatch.dylib"; StackFramePC = 7002132832; StackFrameSymbolName = "__dispatch_client_callout"; }, { StackFrameModule = "libdispatch.dylib"; StackFramePC = 7002139048; StackFrameSymbolName = "__dispatch_once_callout"; }, { StackFrameModule = "libPackageDescription.dylib"; StackFramePC = 4465283448; StackFrameSymbolName = "_$s18PackageDescription7ContextV11environmentSDyS2SGvgZ"; }, { StackFrameModule = "manifest_bjwdoqlmuklnzyeenvxrrponpzzy"; StackFramePC = 4377719596; StackFrameSymbolName = "_main"; }, { StackFrameModule = ExecutionExtension; StackFramePC = 4374972024; }, { StackFrameModule = CoreFoundation; StackFramePC = 6869403044; StackFrameSymbolName = "___CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__"; }, { StackFrameModule = CoreFoundation; StackFramePC = 6869330004; StackFrameSymbolName = "___CFRunLoopDoBlocks"; }, { StackFrameModule = CoreFoundation; StackFramePC = 6869327644; StackFrameSymbolName = "___CFRunLoopRun"; }, { StackFrameModule = CoreFoundation; StackFramePC = 6869325588; StackFrameSymbolName = "_CFRunLoopRunSpecific"; }, { StackFrameModule = GraphicsServices; StackFramePC = 8138953156; StackFrameSymbolName = "_GSEventRunModal"; }, { StackFrameModule = UIKitCore; StackFramePC = 6914872676; StackFrameSymbolName = "-[UIApplication _run]"; }, { StackFrameModule = UIKitCore; StackFramePC = 6915585328; StackFrameSymbolName = "_UIApplicationMain"; }, { StackFrameModule = "libxpc.dylib"; StackFramePC = 9129525396; StackFrameSymbolName = "__xpc_objc_uimain"; }, { StackFrameModule = "libxpc.dylib"; StackFramePC = 9129524880; StackFrameSymbolName = "__xpc_objc_main"; }, { StackFrameModule = "libxpc.dylib"; StackFramePC = 9129534688; StackFrameSymbolName = "__xpc_main"; }, { StackFrameModule = "libxpc.dylib"; StackFramePC = 9129535168; StackFrameSymbolName = "_xpc_main"; }, { StackFrameModule = Foundation; StackFramePC = 6849683752; StackFrameSymbolName = "-[NSXPCListener resume]"; }, { StackFrameModule = PlugInKit; StackFramePC = 7673820444; }, { StackFrameModule = PlugInKit; StackFramePC = 7673820072; }, { StackFrameModule = PlugInKit; StackFramePC = 7673819236; }, { StackFrameModule = PlugInKit; StackFramePC = 7673821304; }, { StackFrameModule = ExtensionFoundation; StackFramePC = 7123324860; StackFrameSymbolName = "_EXExtensionMain"; }, { StackFrameModule = Foundation; StackFramePC = 6850132160; StackFrameSymbolName = "_NSExtensionMain"; }, { StackFrameModule = dyld; StackFramePC = 7502216400; StackFrameSymbolName = start; } ); ThreadCrashed = 1; ThreadID = 461139; ThreadIsMain = 1; }, { StackFrameDictionaries = ( { StackFrameModule = "libsystem_kernel.dylib"; StackFramePC = 8209470608; StackFrameSymbolName = "___workq_kernreturn"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129123016; StackFrameSymbolName = "__pthread_wqthread"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129108616; StackFrameSymbolName = "_start_wqthread"; } ); ThreadID = 461141; }, { DispatchQueueName = "com.apple.root.user-initiated-qos"; StackFrameDictionaries = ( { StackFrameModule = "libsystem_kernel.dylib"; StackFramePC = 8209470748; StackFrameSymbolName = "___ulock_wait2"; }, { StackFrameModule = "libsystem_platform.dylib"; StackFramePC = 9128407640; StackFrameSymbolName = "__os_unfair_lock_lock_slow"; }, { StackFrameModule = "libobjc.A.dylib"; StackFramePC = 6822743572; StackFrameSymbolName = "_objc_sync_enter"; }, { StackFrameModule = PencilKit; StackFramePC = 7952426860; StackFrameSymbolName = "-[PKInkManager inkBehaviorForIdentifier:version:variant:]"; }, { StackFrameModule = PencilKit; StackFramePC = 7952430448; StackFrameSymbolName = "-[PKInk initWithUncheckedIdentifier:color:version:variant:weight:]"; }, { StackFrameModule = PencilKit; StackFramePC = 7952430788; StackFrameSymbolName = "-[PKInk initWithIdentifier:color:version:variant:weight:]"; }, { StackFrameModule = PencilKit; StackFramePC = 7955115692; StackFrameSymbolName = "+[PKInk inkWithIdentifier:color:weight:]"; }, { StackFrameModule = PencilKit; StackFramePC = 7953821656; StackFrameSymbolName = "+[PKTextInputCanvasController defaultInkWithColor:]"; }, { StackFrameModule = PencilKit; StackFramePC = 7953821452; StackFrameSymbolName = "+[PKTextInputCanvasController prewarmFutureCanvasesIfNecessarySecureRendering:]"; }, { StackFrameModule = PencilKit; StackFramePC = 7953196616; StackFrameSymbolName = "___40-[PKTextInputInteraction didMoveToView:]_block_invoke.32"; }, { StackFrameModule = "libdispatch.dylib"; StackFramePC = 7002125312; StackFrameSymbolName = "__dispatch_call_block_and_release"; }, { StackFrameModule = "libdispatch.dylib"; StackFramePC = 7002132832; StackFrameSymbolName = "__dispatch_client_callout"; }, { StackFrameModule = "libdispatch.dylib"; StackFramePC = 7002206152; StackFrameSymbolName = "__dispatch_root_queue_drain"; }, { StackFrameModule = "libdispatch.dylib"; StackFramePC = 7002207736; StackFrameSymbolName = "__dispatch_worker_thread2"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129122880; StackFrameSymbolName = "__pthread_wqthread"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129108616; StackFrameSymbolName = "_start_wqthread"; } ); ThreadID = 461142; }, { StackFrameDictionaries = ( { StackFrameModule = "libsystem_kernel.dylib"; StackFramePC = 8209470608; StackFrameSymbolName = "___workq_kernreturn"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129123016; StackFrameSymbolName = "__pthread_wqthread"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129108616; StackFrameSymbolName = "_start_wqthread"; } ); ThreadID = 461143; }, { StackFrameDictionaries = ( { StackFrameModule = "libsystem_kernel.dylib"; StackFramePC = 8209470608; StackFrameSymbolName = "___workq_kernreturn"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129123016; StackFrameSymbolName = "__pthread_wqthread"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129108616; StackFrameSymbolName = "_start_wqthread"; } ); ThreadID = 461144; }, { StackFrameDictionaries = ( { StackFrameModule = "libsystem_kernel.dylib"; StackFramePC = 8209470608; StackFrameSymbolName = "___workq_kernreturn"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129123016; StackFrameSymbolName = "__pthread_wqthread"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129108616; StackFrameSymbolName = "_start_wqthread"; } ); ThreadID = 461145; }, { StackFrameDictionaries = ( { StackFrameModule = "libsystem_kernel.dylib"; StackFramePC = 8209471240; StackFrameSymbolName = "_mach_msg2_trap"; }, { StackFrameModule = "libsystem_kernel.dylib"; StackFramePC = 8209485336; StackFrameSymbolName = "_mach_msg2_internal"; }, { StackFrameModule = "libsystem_kernel.dylib"; StackFramePC = 8209485104; StackFrameSymbolName = "_mach_msg_overwrite"; }, { StackFrameModule = "libsystem_kernel.dylib"; StackFramePC = 8209484668; StackFrameSymbolName = "_mach_msg"; }, { StackFrameModule = CoreFoundation; StackFramePC = 6869330372; StackFrameSymbolName = "___CFRunLoopServiceMachPort"; }, { StackFrameModule = CoreFoundation; StackFramePC = 6869327992; StackFrameSymbolName = "___CFRunLoopRun"; }, { StackFrameModule = CoreFoundation; StackFramePC = 6869325588; StackFrameSymbolName = "_CFRunLoopRunSpecific"; }, { StackFrameModule = Foundation; StackFramePC = 6849024176; StackFrameSymbolName = "-[NSRunLoop(NSRunLoop) runMode:beforeDate:]"; }, { StackFrameModule = Foundation; StackFramePC = 6849023744; StackFrameSymbolName = "-[NSRunLoop(NSRunLoop) runUntilDate:]"; }, { StackFrameModule = UIKitCore; StackFramePC = 6914951340; StackFrameSymbolName = "-[UIEventFetcher threadMain]"; }, { StackFrameModule = Foundation; StackFramePC = 6849094124; StackFrameSymbolName = "___NSThread__start__"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129128828; StackFrameSymbolName = "__pthread_start"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129108628; StackFrameSymbolName = "_thread_start"; } ); ThreadID = 461146; ThreadName = "com.apple.uikit.eventfetch-thread"; }, { StackFrameDictionaries = ( { StackFrameModule = "libsystem_kernel.dylib"; StackFramePC = 8209470608; StackFrameSymbolName = "___workq_kernreturn"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129123016; StackFrameSymbolName = "__pthread_wqthread"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129108616; StackFrameSymbolName = "_start_wqthread"; } ); ThreadID = 461147; }, { StackFrameDictionaries = ( { StackFrameModule = "libsystem_kernel.dylib"; StackFramePC = 8209470608; StackFrameSymbolName = "___workq_kernreturn"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129123016; StackFrameSymbolName = "__pthread_wqthread"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129108616; StackFrameSymbolName = "_start_wqthread"; } ); ThreadID = 461148; }, { DispatchQueueName = "com.apple.root.user-initiated-qos"; StackFrameDictionaries = ( { StackFrameModule = "libobjc.A.dylib"; StackFramePC = 6822702140; StackFrameSymbolName = "__ZL25getMethodFromRelativeListP20relative_list_list_tI13method_list_tEP13objc_selector"; }, { StackFrameModule = "libobjc.A.dylib"; StackFramePC = 6822694876; StackFrameSymbolName = "_lookUpImpOrForward"; }, { StackFrameModule = "libobjc.A.dylib"; StackFramePC = 6822687972; StackFrameSymbolName = "__objc_msgSend_uncached"; }, { StackFrameModule = PencilKit; StackFramePC = 7952437852; StackFrameSymbolName = "+[PKInkParser inkRenderingDescriptorWithDictionary:]"; }, { StackFrameModule = PencilKit; StackFramePC = 7952440336; StackFrameSymbolName = "+[PKInkParser inkBehaviorsWithIdentifer:version:]"; }, { StackFrameModule = PencilKit; StackFramePC = 7952426964; StackFrameSymbolName = "-[PKInkManager inkBehaviorForIdentifier:version:variant:]"; }, { StackFrameModule = PencilKit; StackFramePC = 7952430448; StackFrameSymbolName = "-[PKInk initWithUncheckedIdentifier:color:version:variant:weight:]"; }, { StackFrameModule = PencilKit; StackFramePC = 7952430788; StackFrameSymbolName = "-[PKInk initWithIdentifier:color:version:variant:weight:]"; }, { StackFrameModule = PencilKit; StackFramePC = 7955115692; StackFrameSymbolName = "+[PKInk inkWithIdentifier:color:weight:]"; }, { StackFrameModule = PencilKit; StackFramePC = 7953821656; StackFrameSymbolName = "+[PKTextInputCanvasController defaultInkWithColor:]"; }, { StackFrameModule = PencilKit; StackFramePC = 7953821452; StackFrameSymbolName = "+[PKTextInputCanvasController prewarmFutureCanvasesIfNecessarySecureRendering:]"; }, { StackFrameModule = PencilKit; StackFramePC = 7953196616; StackFrameSymbolName = "___40-[PKTextInputInteraction didMoveToView:]_block_invoke.32"; }, { StackFrameModule = "libdispatch.dylib"; StackFramePC = 7002125312; StackFrameSymbolName = "__dispatch_call_block_and_release"; }, { StackFrameModule = "libdispatch.dylib"; StackFramePC = 7002132832; StackFrameSymbolName = "__dispatch_client_callout"; }, { StackFrameModule = "libdispatch.dylib"; StackFramePC = 7002206152; StackFrameSymbolName = "__dispatch_root_queue_drain"; }, { StackFrameModule = "libdispatch.dylib"; StackFramePC = 7002207736; StackFrameSymbolName = "__dispatch_worker_thread2"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129122880; StackFrameSymbolName = "__pthread_wqthread"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129108616; StackFrameSymbolName = "_start_wqthread"; } ); ThreadID = 461149; }, { StackFrameDictionaries = ( { StackFrameModule = "libsystem_kernel.dylib"; StackFramePC = 8209470608; StackFrameSymbolName = "___workq_kernreturn"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129123016; StackFrameSymbolName = "__pthread_wqthread"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129108616; StackFrameSymbolName = "_start_wqthread"; } ); ThreadID = 461150; }, { StackFrameDictionaries = ( { StackFrameModule = "libsystem_kernel.dylib"; StackFramePC = 8209470608; StackFrameSymbolName = "___workq_kernreturn"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129123016; StackFrameSymbolName = "__pthread_wqthread"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129108616; StackFrameSymbolName = "_start_wqthread"; } ); ThreadID = 461151; }, { StackFrameDictionaries = ( { StackFrameModule = "libsystem_kernel.dylib"; StackFramePC = 8209470608; StackFrameSymbolName = "___workq_kernreturn"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129123016; StackFrameSymbolName = "__pthread_wqthread"; }, { StackFrameModule = "libsystem_pthread.dylib"; StackFramePC = 9129108616; StackFrameSymbolName = "_start_wqthread"; } ); ThreadID = 461152; }, { StackFrameDictionaries = ( ); ThreadID = 461153; } ) , "ExceptionType": 6, "ExceptionData": <01000000 00000000 a891d797 01000000>, "CrashCatcherPID": 1333, "SignalNumber": 5]))) in https://github.com/apple/swift-async-algorithms ```

It seems that Context is not safe on Swift Playgrounds. If Context.environment is used in Package.swift, Swift Playgrounds's SwiftPM will crash.

kkebo commented 5 months ago

I also sent a feedback to Swift Playgrounds. FB13946579

kkebo commented 5 months ago

Enclosing Context.environment with something like #if !os(iOS) would solve the problem. However, it may become a debt when the new Swift runtime other than Swift Playgrounds appears in the future on iOS or iPadOS.

FranzBusch commented 5 months ago

Thanks for reporting this. This isn't an async-algorithms problem but rather a Swift Playgrounds/Swift PM problem. I am going to close this issue since this is now being tracked in the feedback you filed.

kkebo commented 5 months ago

OK, thank you.