Last active
October 23, 2019 19:45
-
-
Save steipete/f55e4617b7f1cb1ab90e75c7c3e2c95c to your computer and use it in GitHub Desktop.
SpringboardDestroyer. Too many background tasks make Frontboard very sad. See http://openradar.appspot.com/32482871
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let badwork = { (queue: DispatchQueue) in | |
queue.async { | |
let app = UIApplication.shared | |
for index in 0..<100000 { | |
let name = "Yolo \(index)" | |
let identifier = app.beginBackgroundTask(withName: name, expirationHandler: { | |
print("Expired") | |
}); | |
print("Started \(identifier)") | |
let time = DispatchTime.now() + Double(arc4random_uniform(1000))/10.0 | |
queue.asyncAfter(deadline: time, execute: { | |
app.endBackgroundTask(identifier) | |
print("Ended \(identifier)") | |
}) | |
} | |
} | |
} | |
let userQueue = DispatchQueue.global(qos: .userInitiated) | |
badwork(userQueue) | |
let defaultQueue = DispatchQueue.global(qos: .default) | |
badwork(defaultQueue) | |
let interactiveQueue = DispatchQueue.global(qos: .userInteractive) | |
badwork(interactiveQueue) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment