-
Notifications
You must be signed in to change notification settings - Fork 747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
window being accessed from background thread when dequeueNext is called #535
Comments
Don't enqueue view on a background thread. You an either move onto the main queue yourself or call the version of |
Hello @wtmoose ty for the quick reply. Maybe I did not understood your comment, but I am not enqueueing views in a background thread. Please take a look at the following view controller sample (i can also provide the full xcode project if you prefer): class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .gray
}
private func showToastWithMessage(_ message: String) {
SwiftMessages.hideAll()
let toastView = ToastView()
toastView.titleLabel.text = message
var config = SwiftMessages.defaultConfig
config.ignoreDuplicates = false
config.duration = .seconds(seconds: 3)
config.presentationContext = .window(windowLevel: .normal)
SwiftMessages.show(config: config, view: toastView)
}
override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
if let key = presses.first?.key {
self.showToastWithMessage("Press begand with key code: \(key.keyCode.rawValue)")
}
super.pressesBegan(presses, with: event)
}
override func pressesEnded(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
if let key = presses.first?.key {
self.showToastWithMessage("Press ended with key code: \(key.keyCode.rawValue)")
}
super.pressesEnded(presses, with: event)
}
} You can try this out by simply runing it on a simulator, pressing the Mac keyboard keys in quick succession. This will fire the I hope this clarifies the issue. |
Sorry about the misunderstanding. I'm able to reproduce accessing |
Same for me, did not see this behaviour before |
Doesn't seem like it is breaking any functionality, but on my todo list. |
Actually it is for me, when app is going from background to foreground, but I just using version prior to this change now. |
@IceFloe what happens? |
I am doing showing and hiding full screen view based on library presentation logic from the MainActor and it is lagging a little because of this error and not hiding, with old version everything is ok.
|
@joaomvfsantos Could you pull down the head of While fixing this, I made quite a few changes:
|
@wtmoose I can no longer reproduce this when using the master branch, so it seems to be fixed. Thank you! |
Great. I'm going to release this as a beta for a while before making it an official release due to the number of changes. |
dequeueNext
is being called from a background queue here.This in turn does a check to the
isOrphaned
property here.The
isOrphaned
property does a check to theview.window
property here.This triggers an XCode warning with "UIView.window must be used from main thread only". This can lead to possible crashes.
The text was updated successfully, but these errors were encountered: