Skip to content

Instantly share code, notes, and snippets.

@steipete
Last active October 23, 2019 19:45
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steipete/f55e4617b7f1cb1ab90e75c7c3e2c95c to your computer and use it in GitHub Desktop.
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
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