AsyncRenderer causes crashes in ForEach when in Swift 6 language mode

Hi!

We've recently done a big migration to Swift 6 language mode in our app and are now getting reports of crashes occurring due to closures in our SwiftUI code (most often the view builder in ForEach) not running on the main queue but instead running on the queue com.apple.SwiftUI.AsyncRenderer. One example of a call stack (ScheduleListView is our view that is in Swift 6 mode):

Thread 16
#0	(null) in _dispatch_assert_queue_fail ()
#1	(null) in dispatch_assert_queue$V2.cold.1 ()
#2	(null) in dispatch_assert_queue ()
#3	(null) in swift_task_isCurrentExecutorWithFlagsImpl(swift::SerialExecutorRef, swift::swift_task_is_current_executor_flag) ()
#4	(null) in closure #2 in closure #1 in closure #1 in ScheduleListView.body.getter ()
#5	(null) in closure #1 in ForEachState.item(at:offset:) ()
#6	(null) in partial apply for closure #1 in ForEachState.item(at:offset:) ()
#8	(null) in partial apply for closure #1 in _withObservation<A>(do:) ()
....

(We have many other crashes with similar crash reports but in other views)

Has anybody else run into something similar? Is there anything (other than simply reverting to Swift 5 mode again) that we can do to fix or at least reduce the amount of crashes? We're having a hard time finding anything out of the ordinary that we're doing in our views.

Regards

Answered by DTS Engineer in 860776022

Could you open a bug report, include the symbolicated crash report and post the FB number here once you do. Bug Reporting: How and Why? has tips on creating your bug report.

Could you open a bug report, include the symbolicated crash report and post the FB number here once you do. Bug Reporting: How and Why? has tips on creating your bug report.

Thank you!

We've now submitted a bug report (FB20692404).

AsyncRenderer causes crashes in ForEach when in Swift 6 language mode
 
 
Q