Post not yet marked as solved
Here’s the only code in my codebase that uses TaskGroup.
// Function that processes a bunch of 'action triggers' and produces a stream of actions
func run(action: Action, find: @escaping (Model.Type) -> Model?) -> AsyncStream<Action> {
AsyncStream { continuation in
Task {
await withTaskGroup(of: Void.self) { group in
for trigger in triggers {
group.addTask {
for await result in trigger(action, find) {
if result is VoidAction { continue }
continuation.yield(result)
}
}
}
await group.waitForAll()
continuation.finish()
}
}
}
}
// Later, from an async context. Process an action and dispatch its output.
Task {
for await output in run(action: action, find: { store.find($0) }) {
try await store.dispatch(output)
}
}
I was able to solve the crash by explicitly marking both the task group’s closures as @MainActor. But would love to get a deeper understanding of why this doesn’t work.
await withTaskGroup(of: Void.self) { @MainActor group in
for trigger in triggers {
group.addTask { @MainActor in
for await result in trigger(action, find) {
if result is VoidAction { continue }
continuation.yield(result)
}
}
}
await group.waitForAll()
continuation.finish()
}
Post not yet marked as solved
It looks like you can work around this using a wrapping closure:
Button(action: { cancelled() }) { Text("Cancel") }
Ok, after some investigation it looks like kLSRErrorDomain/301 is new in iOS15 and is reported when you cancel a speech recognition request, but only on newer devices (specifically, devices with a CoreML-compatible neural engine — A12 Bionic and newer).
So it looks like iOS15 changes the way speech recognition is handled by the neural engine, resulting in a new error code. Cancelling tasks previously seemed to result in a kAFAssistantErrorDomain/216. 216 is still present in iOS15 though, not sure on the details.
The answer to this, ultimately, was to ditch using RemoteIO and use AVAudioEngine. It has a TON of its own quirks (have fun hunting down crashes when you make even the tiniest mistake with connections and formats or engine lifecycle), but if you respond to the engine reset event it mostly continues working when Sound Recognition is toggle on and off.
Post not yet marked as solved
I’m also seeing this. The obvious answer is that my code is doing what the AVAudioEngine documentation warns against — deallocating within the notification handler.
But while I do deallocate the engine as a result of the notification, I do it asynchronously on another queue so I can’t figure out why I’m getting this deadlock.
Post not yet marked as solved
I'm getting similar errors when trying to use AVPlayer. Basic video works albeit with a flood of console messages and very high CPU use, but I'm trying to load an AVVideoComposition and that doesn’t seem to work.2019-08-02 08:40:18.930240+0100 Test2[83772:18332498] [Common] _BSMachError: port 5803; (os/kern) invalid capability (0x14) "Unable to insert COPY_SEND"
2019-08-02 08:40:18.934754+0100 Test2[83772:18332613] [] [08:40:18.935] composeSceneDo signalled err=-17204 (kFigCaptionRendererError_InvalidState) (_fcrtrigger is NULL) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/EmbeddedCoreMedia_Sim/EmbeddedCoreMedia-2501.6.1.1/Prototypes/Captions/FigCaptionRenderer/FigCaptionRendererSession.c:2268
2019-08-02 08:40:18.972268+0100 Test2[83772:18332708] [] [08:40:18.972] VMC2SetProperty signalled err=-12823 (kVMCParameterErr) (not a CFString) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/EmbeddedCoreMedia_Sim/EmbeddedCoreMedia-2501.6.1.1/Prototypes/MediaConverter/VideoMediaConverter2.c:6655
2019-08-02 08:40:18.981145+0100 Test2[83772:18332615] [] nw_endpoint_flow_copy_multipath_subflow_counts Called on non-Multipath connection
2019-08-02 08:40:19.057537+0100 Test2[83772:18332708] [] [08:40:19.058] piqca_getCAFormatCodeForPixelFormat signalled err=-12814 (kFigImageQueueCannotEnqueueErr) (non-CoreAnimation-supported pixel format) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/EmbeddedCoreMedia_Sim/EmbeddedCoreMedia-2501.6.1.1/Prototypes/VisualContexts/FigImageQueueForCoreAnimation.c:2909
2019-08-02 08:40:19.360663+0100 Test2[83772:18332613] [] nw_endpoint_flow_copy_multipath_subflow_counts Called on non-Multipath connection
2019-08-02 08:44:18.490523+0100 Test2[83772:18342963] [] nw_endpoint_flow_copy_multipath_subflow_counts Called on non-Multipath connection
2019-08-02 08:44:18.495707+0100 Test2[83772:18342963] [] nw_connection_receive_internal_block_invoke [C1] Receive reply failed with error "Operation canceled"
2019-08-02 08:44:18.495815+0100 Test2[83772:18342963] [] nw_connection_receive_internal_block_invoke [C1] Receive reply failed with error "Operation canceled"
2019-08-02 08:44:18.495955+0100 Test2[83772:18342963] [] nw_connection_receive_internal_block_invoke [C1] Receive reply failed with error "Operation canceled"
2019-08-02 08:44:18.496110+0100 Test2[83772:18342963] [] nw_connection_receive_internal_block_invoke [C1] Receive reply failed with error "Operation canceled"