-
-
Notifications
You must be signed in to change notification settings - Fork 480
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
[OSX] Crash when moving OpenGL context to another thread #1300
Comments
It appears to crash during
|
I'd need to retest it with macOS, but I think the issue should be there after #1435. Solving it should be possibly though, given that we can use |
I've looked in apple docs for that and it seems that it's fine https://developer.apple.com/documentation/appkit/nsopenglcontext/1436135-update?language=objc |
We discussed this on Matrix, I could not reproduce the original issue on my machine (running macOS 10.14.6), neither on Even with the following diff (which is not safe, but for illustration) I did not get the crash: diff --git a/glutin_examples/examples/window.rs b/glutin_examples/examples/window.rs
index 0b09a8a..0b1e596 100644
--- a/glutin_examples/examples/window.rs
+++ b/glutin_examples/examples/window.rs
@@ -66,17 +66,22 @@ fn main() {
match event {
Event::WindowEvent { event, .. } => match event {
WindowEvent::Resized(size) => {
- if size.width != 0 && size.height != 0 {
- // Some platforms like EGL require resizing GL surface to update the size
- // Notable platforms here are Wayland and macOS, other don't require it
- // and the function is no-op, but it's wise to resize it for portability
- // reasons.
- gl_window.surface.resize(
- &gl_context,
- NonZeroU32::new(size.width).unwrap(),
- NonZeroU32::new(size.height).unwrap(),
- );
- }
+ use glutin::context::{AsRawContext, RawContext};
+ // `objc = "0.2.7"`
+ use objc::{msg_send, sel, sel_impl};
+
+ dbg!(size);
+ struct ThreadSafe<T>(T);
+ unsafe impl<T> Send for ThreadSafe<T> {}
+ let raw = ThreadSafe(gl_context.raw_context());
+ std::thread::spawn(|| {
+ let raw = raw;
+ let raw: *const objc::runtime::Object = match raw.0 {
+ RawContext::Cgl(x) => x.cast(),
+ };
+
+ let _: () = unsafe { msg_send![raw, update] };
+ });
},
WindowEvent::CloseRequested => {
*control_flow = ControlFlow::Exit; |
I can't seem to be able to move an OpenGL context to another thread on OSX.
Calling
make_current()
on aNotCurrent
context (even splitted) from a non-main thread results in an illegal hardware instruction.Any ideas?
Here is a modified
window.rs
example:The text was updated successfully, but these errors were encountered: