daneden / Twift

🐦 An async Swift library for the Twitter v2 API 🚧 WIP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] UI API called on a background thread in Demo App

coughski opened this issue · comments

In the Demo App, an AsyncButton calls

Twift.Authentication().authenticateUser(clientId: String,
                               redirectUri: URL,
                               scope: Set<OAuth2Scope>,
                               presentationContextProvider: ASWebAuthenticationPresentationContextProviding? = nil
  ) async throws -> OAuth2User

when pressed, which results in a UI hang and the following warning:
Main Thread Checker: UI API called on a background thread: -[UIWindow init]

It looks like presentationAnchor(for session: ASWebAuthenticationSession) is being called from a background thread, instead of the main thread.

I'm using similar code in my app and seeing the same issue; does this need to be fixed within Twift or is there a workaround?

Thanks.