shaps80 / SwiftUIBackports

A collection of SwiftUI backports for iOS, macOS, tvOS and watchOS
MIT License
931 stars 59 forks source link

XCPreviewAgent crash when using the .task modifier in Xcode 14 #27

Closed johnrogers closed 1 year ago

johnrogers commented 1 year ago

General Information

Describe the bug

Since adding .backport.task { await someAsyncWork() } to my SwiftUI views, XCPreviewAgent crashes. Removing the modifier again makes the preview appear.

Steps to reproduce

Implement the task modifier on a SwiftUI view in Xcode and observe that the preview agent crashes.

Expected behavior

The preview works.

Stack trace, compiler error, code snippets

CrashReportError: XCPreviewAgent crashed

XCPreviewAgent crashed. Check ~/Library/Logs/DiagnosticReports for crash logs from your application.

Process: XCPreviewAgent[97637]
Date/Time: 2022-09-27 03:42:32 +0000
Log File: <none>

Application Specific Information:
    libsystem_sim_platform.dylib [
        CoreSimulator 857.7 - Device: iPhone 13 Pro (331455B1-A4E2-4BB6-A161-52F6E4F58603) - Runtime: iOS 15.5 (19F70) - DeviceType: iPhone 13 Pro
    ]
    dyld_sim [
        dyld4 config: DYLD_ROOT_PATH=/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/jrogers/Library/Developer/Xcode/DerivedData/Redacted-edjkeuwkldrlgchgtbyjqwvpgezb/Build/Intermediates.noindex/Previews/Redacted/Products/Debug-iphonesimulator DYLD_INSERT_LIBRARIES=/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot//System/Library/PrivateFrameworks/PreviewsInjection.framework/PreviewsInjection DYLD_FRAMEWORK_PATH=/Users/jrogers/Library/Developer/Xcode/DerivedData/Redacted-edjkeuwkldrlgchgtbyjqwvpgezb/Build/Intermediates.noindex/Previews/Redacted/Products/Debug-iphonesimulator
    ]
    dyld [
        dyld4 config: DYLD_ROOT_PATH=/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/jrogers/Library/Developer/Xcode/DerivedData/Redacted-edjkeuwkldrlgchgtbyjqwvpgezb/Build/Intermediates.noindex/Previews/Redacted/Products/Debug-iphonesimulator DYLD_INSERT_LIBRARIES=/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot//System/Library/PrivateFrameworks/PreviewsInjection.framework/PreviewsInjection DYLD_FRAMEWORK_PATH=/Users/jrogers/Library/Developer/Xcode/DerivedData/Redacted-edjkeuwkldrlgchgtbyjqwvpgezb/Build/Intermediates.noindex/Previews/Redacted/Products/Debug-iphonesimulator
    ]

Frames: [
    Frame {
        imageIndex: 0
        imageOffset: 0
        symbol: <none>
        symbolLocation: <none>
    }
    Frame {
        imageIndex: 1
        imageOffset: 122464
        symbol: protocol witness for View.body.getter in conformance ViewNameRedactedForPrivacy
        symbolLocation: 24
    }
    Frame {
        imageIndex: 2
        imageOffset: 2760140
        symbol: partial apply for closure #1 in ViewBodyAccessor.updateBody(of:changed:)
        symbolLocation: 28
    }
    Frame {
        imageIndex: 2
        imageOffset: 7873668
        symbol: closure #1 in BodyAccessor.setBody(_:)
        symbolLocation: 44
    }
    Frame {
        imageIndex: 2
        imageOffset: 2759904
        symbol: ViewBodyAccessor.updateBody(of:changed:)
        symbolLocation: 1400
    }
    Frame {
        imageIndex: 2
        imageOffset: 7875384
        symbol: DynamicBody.updateValue()
        symbolLocation: 512
    }
    Frame {
        imageIndex: 2
        imageOffset: 9794408
        symbol: partial apply for implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
        symbolLocation: 28
    }
    Frame {
        imageIndex: 3
        imageOffset: 24936
        symbol: AG::Graph::UpdateStack::update()
        symbolLocation: 516
    }
    Frame {
        imageIndex: 3
        imageOffset: 26316
        symbol: AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
        symbolLocation: 400
    }
    Frame {
        imageIndex: 3
        imageOffset: 52540
        symbol: AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
        symbolLocation: 544
    }
    Frame {
        imageIndex: 3
        imageOffset: 140496
        symbol: AGGraphGetValue
        symbolLocation: 232
    }
    Frame {
        imageIndex: 2
        imageOffset: 7904780
        symbol: AnyViewList.updateValue()
        symbolLocation: 76
    }
    Frame {
        imageIndex: 2
        imageOffset: 1664928
        symbol: partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
        symbolLocation: 20
    }
    Frame {
        imageIndex: 3
        imageOffset: 24936
        symbol: AG::Graph::UpdateStack::update()
        symbolLocation: 516
    }
    Frame {
        imageIndex: 3
        imageOffset: 26316
        symbol: AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
        symbolLocation: 400
    }
    Frame {
        imageIndex: 3
        imageOffset: 52540
        symbol: AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
        symbolLocation: 544
    }
    Frame {
        imageIndex: 3
        imageOffset: 140496
        symbol: AGGraphGetValue
        symbolLocation: 232
    }
    Frame {
        imageIndex: 2
        imageOffset: 10195940
        symbol: _ViewList_Group.Init.value.getter
        symbolLocation: 184
    }
    Frame {
        imageIndex: 2
        imageOffset: 1274680
        symbol: specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
        symbolLocation: 36
    }
    Frame {
        imageIndex: 3
        imageOffset: 24936
        symbol: AG::Graph::UpdateStack::update()
        symbolLocation: 516
    }
    Frame {
        imageIndex: 3
        imageOffset: 26316
        symbol: AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
        symbolLocation: 400
    }
    Frame {
        imageIndex: 3
        imageOffset: 52540
        symbol: AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, unsigned char&, long)
        symbolLocation: 544
    }
    Frame {
        imageIndex: 3
        imageOffset: 140496
        symbol: AGGraphGetValue
        symbolLocation: 232
    }
    Frame {
        imageIndex: 2
        imageOffset: 7906496
        symbol: AnyViewList.Item.list.getter
        symbolLocation: 120
    }
    Frame {
        imageIndex: 2
        imageOffset: 7905140
        symbol: AnyViewList.updateValue()
        symbolLocation: 436
    }
    Frame {
        imageIndex: 2
        imageOffset: 1664928
        symbol: partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
        symbolLocation: 20
    }
    Frame {
        imageIndex: 3
        imageOffset: 24936
        symbol: AG::Graph::UpdateStack::update()
        symbolLocation: 516
    }
    Frame {
        imageIndex: 3
        imageOffset: 26316
        symbol: AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int)
        symbolLocation: 400
    }
    Frame {
        imageIndex: 3
        imageOffset: 50544
        symbol: AG::Graph::value_ref(AG::AttributeID, AGSwiftMetadata const*, unsigned char&)
        symbolLocation: 160
    }
    Frame {
        imageIndex: 3
        imageOffset: 140572
        symbol: AGGraphGetValue
        symbolLocation: 308
    }
    Frame {
        imageIndex: 2
        imageOffset: 2183124
        symbol: TestableViewContent.list.getter
        symbolLocation: 100
    }
    Frame {
        imageIndex: 2
        imageOffset: 2182240
        symbol: TestableViewContent.children.getter
        symbolLocation: 44
    }
    Frame {
        imageIndex: 2
        imageOffset: 2181596
        symbol: View.withChildrenForTest<A>(environment:options:body:)
        symbolLocation: 192
    }
    Frame {
        imageIndex: 2
        imageOffset: 5936640
        symbol: View._allPreviews.getter
        symbolLocation: 104
    }
    Frame {
        imageIndex: 2
        imageOffset: 5936480
        symbol: MakePreviews.visit<A>(type:)
        symbolLocation: 156
    }
    Frame {
        imageIndex: 2
        imageOffset: 11123448
        symbol: _callVisitViewType2
        symbolLocation: 44
    }
    Frame {
        imageIndex: 2
        imageOffset: 5936280
        symbol: static _PreviewProvider._allPreviews.getter
        symbolLocation: 172
    }
    Frame {
        imageIndex: 4
        imageOffset: 147008
        symbol: <none>
        symbolLocation: <none>
    }
    Frame {
        imageIndex: 4
        imageOffset: 146736
        symbol: <none>
        symbolLocation: <none>
    }
    Frame {
        imageIndex: 4
        imageOffset: 116768
        symbol: <none>
        symbolLocation: <none>
    }
    Frame {
        imageIndex: 4
        imageOffset: 99416
        symbol: <none>
        symbolLocation: <none>
    }
    Frame {
        imageIndex: 4
        imageOffset: 97520
        symbol: <none>
        symbolLocation: <none>
    }
    Frame {
        imageIndex: 4
        imageOffset: 98252
        symbol: <none>
        symbolLocation: <none>
    }
    Frame {
        imageIndex: 5
        imageOffset: 20488
        symbol: +[BSXPCServiceConnectionProxy invokeMethod:onTarget:withMessage:forConnection:]
        symbolLocation: 1232
    }
    Frame {
        imageIndex: 5
        imageOffset: 74448
        symbol: __63-[BSXPCServiceConnectionEventHandler connection:handleMessage:]_block_invoke
        symbolLocation: 624
    }
    Frame {
        imageIndex: 5
        imageOffset: 235828
        symbol: BSXPCServiceConnectionExecuteCallOut
        symbolLocation: 304
    }
    Frame {
        imageIndex: 5
        imageOffset: 73436
        symbol: -[BSXPCServiceConnectionEventHandler connection:handleMessage:]
        symbolLocation: 156
    }
    Frame {
        imageIndex: 5
        imageOffset: 232492
        symbol: -[BSXPCServiceConnection _connection_handleMessage:fromPeer:withHandoff:]
        symbolLocation: 284
    }
    Frame {
        imageIndex: 6
        imageOffset: 8772
        symbol: _dispatch_call_block_and_release
        symbolLocation: 24
    }
    Frame {
        imageIndex: 6
        imageOffset: 15000
        symbol: _dispatch_client_callout
        symbolLocation: 16
    }
    Frame {
        imageIndex: 6
        imageOffset: 43724
        symbol: _dispatch_lane_serial_drain
        symbolLocation: 652
    }
    Frame {
        imageIndex: 6
        imageOffset: 46720
        symbol: _dispatch_lane_invoke
        symbolLocation: 456
    }
    Frame {
        imageIndex: 6
        imageOffset: 70500
        symbol: _dispatch_main_queue_drain
        symbolLocation: 792
    }
    Frame {
        imageIndex: 6
        imageOffset: 69692
        symbol: _dispatch_main_queue_callback_4CF
        symbolLocation: 40
    }
    Frame {
        imageIndex: 7
        imageOffset: 547884
        symbol: __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
        symbolLocation: 12
    }
    Frame {
        imageIndex: 7
        imageOffset: 524464
        symbol: __CFRunLoopRun
        symbolLocation: 2432
    }
    Frame {
        imageIndex: 7
        imageOffset: 520728
        symbol: CFRunLoopRunSpecific
        symbolLocation: 572
    }
    Frame {
        imageIndex: 8
        imageOffset: 13836
        symbol: GSEventRunModal
        symbolLocation: 160
    }
    Frame {
        imageIndex: 9
        imageOffset: 12638872
        symbol: -[UIApplication _run]
        symbolLocation: 992
    }
    Frame {
        imageIndex: 9
        imageOffset: 12658228
        symbol: UIApplicationMain
        symbolLocation: 112
    }
    Frame {
        imageIndex: 2
        imageOffset: 10302100
        symbol: closure #1 in KitRendererCommon(_:)
        symbolLocation: 160
    }
    Frame {
        imageIndex: 2
        imageOffset: 10301936
        symbol: runApp<A>(_:)
        symbolLocation: 164
    }
    Frame {
        imageIndex: 2
        imageOffset: 4220544
        symbol: static App.main()
        symbolLocation: 80
    }
    Frame {
        imageIndex: 10
        imageOffset: 14208
        symbol: <none>
        symbolLocation: <none>
    }
    Frame {
        imageIndex: 11
        imageOffset: 7384
        symbol: start_sim
        symbolLocation: 20
    }
    Frame {
        imageIndex: 12
        imageOffset: 20620
        symbol: start
        symbolLocation: 520
    }
]

Images: [
    Image {
        uuid: 00000000-0000-0000-0000-000000000000
        base: 0
        name: <none>
        path: <none>
    }
    Image {
        uuid: b8a2035a-839d-3f1b-82e1-ae1ed0d8fa6e
        base: 733331456
        name: Redacted_FD5DA5DE38C1551_PackageProduct
        path: /Users/USER/Library/Developer/Xcode/DerivedData/Redacted-edjkeuwkldrlgchgtbyjqwvpgezb/Build/Intermediates.noindex/Previews/Redacted/Products/Debug-iphonesimulator/PackageFrameworks/Redacted_FD5DA5DE38C1551_PackageProduct.framework/Redacted_FD5DA5DE38C1551_PackageProduct
        arch: arm64
    }
    Image {
        uuid: 230fac38-33f4-348b-b676-e5d65157ca8c
        base: 195624960
        name: SwiftUI
        path: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/SwiftUI.framework/SwiftUI
        arch: arm64
    }
    Image {
        uuid: 09d49b75-24ad-3293-b5cd-0121dbb15b97
        base: 92815360
        name: AttributeGraph
        path: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AttributeGraph.framework/AttributeGraph
        arch: arm64
    }
    Image {
        uuid: 12ca1c72-a2ee-3b3b-b6c5-6569b0a74f55
        base: 38551552
        name: PreviewsInjection
        path: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/PreviewsInjection.framework/PreviewsInjection
        arch: arm64
    }
    Image {
        uuid: 7b01370c-32d3-347b-9ec9-9255084d9eee
        base: 333053952
        name: BoardServices
        path: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/BoardServices.framework/BoardServices
        arch: arm64
    }
    Image {
        uuid: a06c95dc-09e7-3a87-afb6-7e1b0bec1287
        base: 59965440
        name: libdispatch.dylib
        path: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib
        arch: arm64
    }
    Image {
        uuid: 673c8a21-98bf-38f0-a038-55ab0de23142
        base: 94666752
        name: CoreFoundation
        path: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
        arch: arm64
    }
    Image {
        uuid: 9334a354-2177-30b1-b919-4fecf59fef22
        base: 84492288
        name: GraphicsServices
        path: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
        arch: arm64
    }
    Image {
        uuid: 7bbc9f13-df06-3c47-9a63-8483442bdfcb
        base: 628752384
        name: UIKitCore
        path: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore
        arch: arm64
    }
    Image {
        uuid: 83c5ea3a-4a49-3f59-8136-67d6353e1f1b
        base: 33865728
        name: XCPreviewAgent
        path: /Users/USER/Library/Developer/Xcode/UserData/Previews/Simulator Devices/331455B1-A4E2-4BB6-A161-52F6E4F58603/data/Containers/Bundle/Application/1A1C8D9D-47B9-4E9B-88CA-D4341D693157/XCPreviewAgent.app/XCPreviewAgent
        arch: arm64
    }
    Image {
        uuid: 67298116-bb18-3438-b22e-8d2b9d4618e9
        base: 37093376
        name: dyld_sim
        path: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot/usr/lib/dyld_sim
        arch: arm64
    }
    Image {
        uuid: 38ee9fe9-b66d-3066-8c5c-6ddf0d6944c6
        base: 35274752
        name: dyld
        path: /usr/lib/dyld
        arch: arm64e
    }
    Image {
        uuid: 92169345-9fa9-3925-bc8b-8a67f59dfcea
        base: 39436288
        name: libswiftCore.dylib
        path: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftCore.dylib
        arch: arm64
    }
    Image {
        uuid: 6de4a53b-8d96-3c92-b3c9-4a5ed84776fb
        base: -871718912
        name: libsystem_pthread.dylib
        path: /usr/lib/system/libsystem_pthread.dylib
        arch: arm64
    }
    Image {
        uuid: 3f1dda9e-9999-35d8-9886-03267422f518
        base: -872067072
        name: libsystem_kernel.dylib
        path: /usr/lib/system/libsystem_kernel.dylib
        arch: arm64
    }
    Image {
        uuid: ded71e05-af0a-3172-b09e-7f070ec7d4aa
        base: 51527680
        name: Foundation
        path: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Foundation.framework/Foundation
        arch: arm64
    }
]

==================================

|  MessageError: Connection interrupted
|  
|  ==================================
|  
|  |  MessageSendFailure: Message send failure for <ServiceMessage 249: update>
shaps80 commented 1 year ago

@johnrogers I'm not able to reproduce this, could you attach a simple project demonstrating the issue please 👍