This got even weirder. One is that sometimes the use of cos() would cause a compiler error, which was fixed by using Darwin.cos(). This may be fixed in Swift 6.3.
The other thing is that in my much more complex code, the crash seemed to be caused by both the cos() call evaluating to 0, but only when the line being drawn with that result had a StrokeStyle applied to it.
In anycase, I have filed Feedbacks explaining this, and I'm told the WindowServer team has had it brought to their attention.
Topic:
UI Frameworks
SubTopic:
SwiftUI