[GH-ISSUE #598] A delay of 1 second on main thread while presenting SafariURLHandler #390

Closed
opened 2026-03-03 16:48:18 +03:00 by kerem · 1 comment
Owner

Originally created by @omiz on GitHub (May 20, 2020).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/598

Description:

I'm trying to use the provided safari controller in SafariURLHandler my implementation is fairly simple

let handler = SafariURLHandler(viewController: self, oauthSwift: self.oauthswift!)

handler.factory = { url in
    let controller = SFSafariViewController(url: url)
    controller.modalPresentationStyle = .formSheet
    return controller
}

but when presenting the controller there is a delay of 1 second. This delay is on the main thread and blocking the UI

I'm talking about the file SafariURLHandler.swift at line 69

if let delay = this.delay { // sometimes safari show a blank view..
    sleep(delay)
}

is there any information on this or what is causing it black view because I would like to remove the delay by setting it to nil because I'm sure that blocking the main thread is never the solution

OAuth Version:

  • Version 2

OS (Please fill the version) :

  • iOS :

Installation method:

  • Swift Package Manager

Library version:

  • v2.1.0

Xcode version:

  • 11.4 (Swift 5.2)
Originally created by @omiz on GitHub (May 20, 2020). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/598 ### Description: I'm trying to use the provided safari controller in `SafariURLHandler` my implementation is fairly simple ```swift let handler = SafariURLHandler(viewController: self, oauthSwift: self.oauthswift!) handler.factory = { url in let controller = SFSafariViewController(url: url) controller.modalPresentationStyle = .formSheet return controller } ``` but when presenting the controller there is a delay of 1 second. This delay is on the main thread and blocking the UI I'm talking about the file SafariURLHandler.swift at line 69 ```swift if let delay = this.delay { // sometimes safari show a blank view.. sleep(delay) } ``` is there any information on this or what is causing it black view because I would like to remove the delay by setting it to `nil` because I'm sure that blocking the main thread is never the solution ### OAuth Version: - [x] Version 2 ### OS (Please fill the version) : - [x] iOS : ### Installation method: - [x] Swift Package Manager ### Library version: - [x] v2.1.0 ### Xcode version: - [x] 11.4 (Swift 5.2)
kerem 2026-03-03 16:48:18 +03:00
Author
Owner

@phimage commented on GitHub (May 24, 2020):

I have no clue. Never tested it, so If you have no issue with nil, why not , maybe an old iOS issue

And yes I am agree about sleep in main thread is not the solution, maybe schedule later the action is better with and async after delay

<!-- gh-comment-id:633296078 --> @phimage commented on GitHub (May 24, 2020): I have no clue. Never tested it, so If you have no issue with nil, why not , maybe an old iOS issue And yes I am agree about sleep in main thread is not the solution, maybe schedule later the action is better with and async after delay
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#390
No description provided.