BackgroundTaskManager Crash from submitting TaskUsing the BGTaskScheduler we are seeing a large amount of crashes from stack traces showing on BGTaskScheduler.shared.submit(). I have verified the following - BG Task is registered only once - Task

Using the BGTaskScheduler we are seeing a large amount of crashes from stack traces showing on BGTaskScheduler.shared.submit().

I have verified the following

  • BG Task is registered only once
  • Task is registered before returning from applicationDidFinishLaunching
  • I have the correct capabilities added Background Fetch
  • Check identifier for task matches string in .plist
  • Task Submit request is performed on a background thread

We are only seeing this issue on iOS 15

Has anyone else experience this issue? I cannot see a way that I am miss-using this API to cause a crash.

// Method called on appDidFinishLaunching
   func registerTimeZoneBGTask() {
    BGTaskScheduler.shared.register(forTaskWithIdentifier: TimeZoneRefreshIdentifier,
                    using: nil) { task in
       // Handle Task
    }
  }

  @objc class func submitTimeZoneUpdateBackgroundTask() {
    do {
      let backgroundAppRefreshRequest = BGAppRefreshTaskRequest(identifier: TimeZoneRefreshIdentifier)
      backgroundAppRefreshRequest.earliestBeginDate = Date(timeIntervalSinceNow: 3600)
// Crash occurs on the next call
      try BGTaskScheduler.shared.submit(backgroundAppRefreshRequest)
    } catch {
      Logger.appLog("TimeZone Refresh - Failed to submit background task")
    }
  }

Have you tried try? BGTaskScheduler.shared.submit(backgroundAppRefreshRequest)

BackgroundTaskManager Crash from submitting TaskUsing the BGTaskScheduler we are seeing a large amount of crashes from stack traces showing on BGTaskScheduler.shared.submit(). I have verified the following - BG Task is registered only once - Task
 
 
Q