Skip to content

FB21792467: Kill The Window Server with MATH #761

@MrTheSaw

Description

@MrTheSaw

Submission Date

2026-28-01

Status

Open

Area

SwiftUI

Operating System Version

macOS 26.2

Type

Incorrect/Unexpected Behavior

Description

am developing a program which draws a bunch of things in SwiftUI. When I set the starting angle to tau*3/4 radians, the Preview didn't.

In fact, the WindowServer hanged. (Not the underlying OS). Eventually the OS noted the lack of response, and killed the Window server.

I have included a minimized example file: ContentView.swift. Note that I commented out the #Preview, as I got tired of blowing up my session. I tested in a VM running 26.2.

I'm pretty sure it's a problem with using cos() and or sin() from the Core Graphics library. I haven't tested it, but I note in a recent FB that sometimes regular sin() sometimes doesn't compile. See: FB21779423

//
//  ContentView.swift
//  WindowServerKillerApp
//
//  Created by Hacksaw on 1/28/26.
//

import SwiftUI
import Foundation

@inline(__always) func pt(_ x: Double, _ y: Double) -> CGPoint {
  CGPoint(x: x, y: y)
}

let tau = 2.0 * Double.pi

let dashStyle = StrokeStyle (
  lineWidth: 2,
  lineCap: .round,
  lineJoin: .miter,
  miterLimit: 0,
  dash: [5, 10],
  dashPhase: 0
)


  struct ContentView: View {
  @State private var spin = false
  @State private var angleUnitsRadians = false
  @State private var angle: Angle = Angle(radians: (tau*3.0)/4.0)
  @State private var size: CGSize = CGSize(width: 800, height: 600)
  @State private var qdt: (qx: Double, qy: Double) = (-1,-1)
  var body: some View {
    let sH = (0.8 * size.height)/2.0

    ZStack {

      let ctr = pt(size.width/2.0, size.height/2.0)

      // draw Secant line indicator
       Path { path in
         path.move(to: pt(0, qdt.qy * -20.0))
          // DIV BY ZERO
         path.addLine(to: pt(qdt.qx * (sH)/cos(angle.radians), qdt.qy * -20))
          }
      .stroke(Color.pink, style: dashStyle)
      .transformEffect(.init(1, 0, 0, -1, ctr.x, ctr.y))


      //Cosecant Line indicator
      Path { path in
        path.move(to: pt(qdt.qx * -20, 0))
        // DIV BY ZERO
        path.addLine(to: pt(qdt.qx * -20, qdt.qy * (sH)/cos(angle.radians)))
      }
      .stroke(Color.orange, style: dashStyle
      ).transformEffect(.init(1, 0, 0, -1, ctr.x, ctr.y))

    }
    // sets the main size @State variable
    .onGeometryChange(for: CGSize.self) {
      proxy in proxy.size
    } action: { newValue, someValue in size = newValue }
      .frame(width: size.width, height: size.height)
      .padding()
  }
}

//#Preview {
//    ContentView()
//
//}

Keywords

WindowServer crash

Prerequisites

  • The title follows the format FB<number>: <title>
  • I will keep this issue updated with Apple's responses

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions