popeye
popeye

Reputation: 21

Hang in [NSOpenGLContext flushBuffer]

I have two NSOpenGLViews, named myView1 and myView2. myView2 is a sub view of myView1. Then I use CVDisplayLinkCreateWithCGDisplay to create a display link for the main display. Both myView1 and myView2 will draw something in the main thread(i.e. in drawRect function) using OpenGL. In the display link callback, I'll also draw something for myView1 using OpenGL.

The drawing codes is something like

[self.openGLContext makeCurrentContext];
[self.openGLContext lock];

//draw something ...

[self.openGLContext flushBuffer];
[self.openGLContext unlock];

Everything works well at this moment. But if I add the following code for both myView1 and myView2, it will easily runs into a hang.

[self setWantsLayer:YES];

The call stack is here: enter image description here

It seems that both the main thread and Display Link callback locks in [NSOpenGLContext flushBuffer]. Does anyone know how to solve this problem?

Upvotes: 2

Views: 241

Answers (0)

Related Questions