-
-
Notifications
You must be signed in to change notification settings - Fork 175
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
#[gtk4::test]
fails with an error "Attempted to initialize GTK on OSX from non-main thread"
#1235
Comments
Seems the problem comes from https://github.com/gtk-rs/gtk4-rs/blob/master/gtk4/src/rt.rs#L99-L107 so someone with access to a macos machine would have to debug this. |
Recently released Rust 1.67 made things somehow worse. Now new threads are spawned for every test. This happened to be an old issue. This stackoverflow question is almost 6 years old. It advises to not to use N.B. I've also found a useful article with details how to organize such tests. |
So, |
#[gtk4::test]
fails with an error "Attempted to initialize GTK on OSX from non-main thread"#[gtk4::test]
fails with an error "Attempted to initialize GTK on OSX from non-main thread"
This seems pretty bad, won't this interfere with testing in every single other GUI crate that binds anything related to appkit? Do we know exactly what functions have to be called on the main thread? I wonder if we can workaround it for now by making CI use a gtk build with the x11 or broadway backend, if that will avoid calling any appkit functions? |
@jf2048 something i tried to do here is to make use of https://developer.apple.com/documentation/dispatch/1453123-dispatch_sync_f, but as i don't have access to a macos and the CI being slow, it was impossible to implement.... |
I just learned that there is actually a wrapper for this macOS dispatch thing. We can use http://sasheldon.com/rust-objc/dispatch/struct.Queue.html#method.sync to achieve what we want I believe. I added it to my to-do list |
See greatscottgadgets/packetry#100 for a workaround that worked for me, using the |
Bug description
Minimal example https://github.com/andy128k/test-gtk-rs-osx
Successful build on Linux https://github.com/andy128k/test-gtk-rs-osx/actions/runs/3828477828/jobs/6514110530
Failure on macos https://github.com/andy128k/test-gtk-rs-osx/actions/runs/3828477834/jobs/6514110710
Backtrace
The text was updated successfully, but these errors were encountered: