macOS Server App on background state

Hi, let us explain the situation we have:

  • We have a macOS server app which happens to be/act as a QUIC server (this setup is for a live demo).
  • Once the server receives a streaming request from the client, server starts to send a bunch of QUIC streams to the client.
  • The server needs to run on a macbook pro for the live demo and everything works fine, now when we click on a different app (the server app looses focus) the server app goes to background state and the network activity just stops going from 90MB/s to almost zero, but when we click on the server app again, the network activity goes back to 90MB/s and it continues normally.
  • We understand this is the OS taking some decisions by managing resources efficiently.

Question: Kindly let us know which options do we have to keep the server app QUIC networking tasks continuously running, even if it is not on the foreground (basically for it to behave like an actual server/service)?

Thanks in advance

Answered by DTS Engineer in 799168022

Question: Kindly let us know which options do we have to keep the server app QUIC networking tasks continuously running, even if it is not on the foreground (basically for it to behave like an actual server/service)?

Which framework/architecture is the app written with (AppKit/macCatalyst/SwiftUI/iOS App compatibility)?

The range of possibilities (and solutions) depend on your answer, but my first thought from your overall description is that your app is that you're running into App Nap. The initial section is focused on extending App Nap, but the later section "Prioritize Work at the App Level" describes how you can use NSProcessInfo to inform the system of what your app is doing, preventing App Nap.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Accepted Answer

Question: Kindly let us know which options do we have to keep the server app QUIC networking tasks continuously running, even if it is not on the foreground (basically for it to behave like an actual server/service)?

Which framework/architecture is the app written with (AppKit/macCatalyst/SwiftUI/iOS App compatibility)?

The range of possibilities (and solutions) depend on your answer, but my first thought from your overall description is that your app is that you're running into App Nap. The initial section is focused on extending App Nap, but the later section "Prioritize Work at the App Level" describes how you can use NSProcessInfo to inform the system of what your app is doing, preventing App Nap.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Thanks for coming back so quickly.

The Server app is based on the SwiftUI framework and is meant to be only a macOS app.

The QUIC networking implementation that the Server app uses, is inside a custom framework we created.

Kindly let us know if you need more details.

Thanks for coming back so quickly. The Server app is based on the SwiftUI framework and is meant to be only a macOS app.

OK, then the issue is very likely to be App Nap. Have you looked at "Prioritize Work at the App Level" and added in activity calls?

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

I tried adding the activity calls and the activity monitor is showing the server app is preventing sleeping. Also I do not see the sleeping behavior anymore, so this was really helpful.

Thank you.

macOS Server App on background state
 
 
Q