vapor/vapor

Hang risk when running on iOS as a file server

tomisacat opened this issue · 2 comments

Describe the bug

I'm trying to embed Vapor into an iOS app as file server following the tutorial from Running a Web Server on iOS with Vapor | Kodeco, but encountered hang risk when running app:

SCR-20230703-qebr

The full warning report is:

Thread Performance Checker: Thread running at QOS_CLASS_USER_INTERACTIVE waiting on a lower QoS thread running at QOS_CLASS_DEFAULT. Investigate ways to avoid priority inversions

To Reproduce

Steps to reproduce the behavior:

  1. Add package with Xcode built-in package manager
  2. Initialize Application and start
  init(port: Int) {
    self.port = port
    app = Application(.production)
    configure(app)
  }

  private func configure(_ app: Application) {
    app.http.server.configuration.hostname = "0.0.0.0"
    app.http.server.configuration.port = port

    app.views.use(.leaf)
    app.leaf.cache.isEnabled = app.environment.isRelease
    app.leaf.configuration.rootDirectory = Bundle.main.bundlePath

    app.routes.defaultMaxBodySize = "50MB"
  }

  func start() {
    Task(priority: .high) {
      do {
        try app.start()
      } catch {
        fatalError(error.localizedDescription)
      }
    }
  }
  1. Call start when app launch, and the error will prompted out.

Expected behavior

No hang risk, just like running Vapor as a server side app.

Environment

  • Vapor Framework version: 4.77.0
  • Vapor Toolbox version: 18.7.1
  • OS version: 13.3.1

Additional context

No

0xTim commented

This is a dupe of apple/swift-nio#2223 and an issue inside NIO - not something we can control unfortunately

@0xTim Thanks for your reply. I think I should adopt the temporary solution as a workaround for the time being.