Playgrounds on Montery crashes if trying to add local network access rights

Howdy from Germany.

I try to add a local httpServer with swift-http-server (https://github.com/bjtj/swift-http-server).

import SwiftUI
import SwiftHttpServer

@main
struct MyApp: App {
  init() {
    print("init")
    let server = HttpServer(port: 9090)
     
    class GetHandler: HttpRequestHandler {
       
      var dumpBody: Bool = true
       
      func onHeaderCompleted(header: HttpHeader, request: HttpRequest, response: HttpResponse) throws {
      }
       
      func onBodyCompleted(body: Data?, request: HttpRequest, response: HttpResponse) throws {
        response.status = .ok
        response.data = "Hello".data(using: .utf8)
      }
    }
     
    do {
      try server.route(pattern: "/", handler: GetHandler())
    } catch let serverError {
      print(serverError)
    }
     
    let queue = DispatchQueue.global(qos: .default)
    queue.async {
      do {
        try server.run()
      } catch let error {
        print(error)
      }
    }
  }
  var body: some Scene {
    WindowGroup {
      ContentView() // Standard ContentView
    }
  }
}

When I try to add the local network rights on macOS (Montery 12.4 21F79) in the Playgrounds.app (Version 4.1 (1676.15)) it crashes everytime I hit the (+) button.

On iPad (Air 4th gen) with latest ipadOS it works fine. I can add the network rights and can serve the little hello page, by entering :9090/

As mentioned on macOS not possible. Of couse if I reload the Playgrounds project on the Mac, the local network rights are now included, but still on the mac the "Hello" page is not served.

Any hints/tips how to solve this problem? Need I to add more rights? Do I have to report the crash somewhere? I have the crashlog.

Thanks in advance.

Alex

PS: Background: I try to write a Playgrounds App which generates some output on a webpage, which then is served via the in-app webserver, which then is integrated on Obs via web page plugin...

In general for testing local network connectivity it is best to test it on a real device if you end target is iPadOS. At the same time, the Playground app should not be crashing in this situation. If you find that it is not a bug in your code and the issue persists then I would create a bug report and add a focused sample to the bug report.

Well, target is an iPad (idea use the iPad as smart touchpad for OBS overlay graphics), but it would be nice if it work on macOS, too, cause not everyone has an iPad. Anyway, as I wrote. On iPad it serves the website without problems and there was no problem to ad the local network rights. The problem exists only on macOS Monterey. Anyway I filed a bug report. Thanks for the link.

Playgrounds on Montery crashes if trying to add local network access rights
 
 
Q