Re: NSOpenGLView from a second NSThread
Re: NSOpenGLView from a second NSThread
- Subject: Re: NSOpenGLView from a second NSThread
- From: Alex Eddy <email@hidden>
- Date: Fri, 21 May 2004 11:11:31 -0700
On May 21, 2004, at 10:00 AM, email@hidden wrote:
I'm using an NSOpenGLView that I call from a second NSThread (other
than the main thread), and only from this thread.
The code works fine, only when I resize the window that holds the view,
I get into a systematical kernel panic.
This is a longstanding problem with multithreaded GL. What's happening
is that your app is submitting GL commands to the same context from two
threads simultaneously, and this corrupts the GL command stream.
Whenever I do this on my Powerbook(s), I get a total system freeze
(white or static screen, no KP overlay.)
I read about the kernel panics and opengl on the web, and I understand
why this is happening, and I'm trying to find the best way to catch
when to stop drawing in the background and when to start again.
This is a programming error on your part, since the GL context must be
treated as a shared resource in a multithreaded application. You are
going to have to create a lock (NS or pthread) and use it around every
possible place where you submit GL commands (drawRect, resize, etc.)
That said, IMHO it is rather bad that you can KP the machine like this
(and it boils down to a handful of code to reproduce it) so I strongly
suggest that you make a reduced test case where this happens, and log a
bug at
http://bugreporter.apple.com about it. User-space applications
shouldn't be able to toast the whole machine!
Since any not working code gets me into a kernel panic, I thought I'd
ask you guys before I got into a loooong loop of restarting my mac ;-)
It usually takes me half a dozen reboots to set up multithreaded GL
apps. :(
-alex
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.