utmapp / UTM

Virtual machines for iOS and macOS
https://getutm.app
Apache License 2.0
26.67k stars 1.34k forks source link

IPSW download speed drops by half when UTM window loses focus #4599

Open LostInCompilation opened 1 year ago

LostInCompilation commented 1 year ago

Describe the issue
If the UTM window loses focus while downloading a macOS VM IPSW image, the download speed drops to about half the speed after one minute. If UTM gains back focus, the download speed gets normal again. The issue was already present in UTM v3, however back then I thought it was just a thing with my internet connection. I now ruled that out, since it's happening every time and the speed drop is very consistent. In the image you can see the download speed (blue). The left and right ends are during focus loss, the middle is while the window is having focus.

Configuration

Screenshot 2022-11-02 at 21 28 13
osy commented 1 year ago

I am unable to reproduce this issue on my system. However, v4.1.1 introduced some changes to the downloader to allow downloads to resume after sleep. Can you test again and see if you still see this issue? Also if you can reproduce it on a separate machine, that may help narrow down the cause.

LostInCompilation commented 1 year ago

Just tested it with the current code on GitHub (4.1.3 I guess) on macOS13.1, same issue. Did you try opening another fullscreen window (I used Safari with a YouTube video playing) on top of UTM and wait for about 1-2 minutes?

osy commented 1 year ago

Hmm in that case if the other app is full screen, it may be an macOS "feature".

LostInCompilation commented 1 year ago

Fullscreen was just another option. It happens also with windowed apps. I just meant big enough to cover the UTM window.

osy commented 1 year ago

Are you on Wifi or ethernet? Is your laptop plugged in or on battery? Do you have anything like low power mode enabled? Are you connecting to a iPhone hotspot?

LostInCompilation commented 1 year ago

WiFi, plugged in, no low power mode, no hotspot.

LostInCompilation commented 1 year ago

Just tested it with Safari closed, still present. But now it takes longer for the speed to drop and it recovers periodically for a few seconds, then dropping again. Quite strange, almost like a priority thing. But I never observed this in other Apps, so I'm not sure this is purely caused by the system.

osy commented 1 year ago

Wonder if it's a bug with Swift Concurrency. It's fairly new and I don't think many apps have adopted it yet.

LostInCompilation commented 1 year ago

@osy Check out this text about IO policies: https://eclecticlight.co/2022/02/28/does-removing-i-o-throttling-make-backups-faster/

I'm sure there is a way to set UTM to IOPOL_IMPORTANT when downloading. However I'm not sure if this is only drive IO or network too.