Which parts of UIKit, Core Graphics, Core Animation, OpenGL are allowed on non main-thread?

"YOU AND THE ART OF ONLINE DATING" is the only product on the market that will take you step-by-step through the process of online dating, provide you with the resources to help ensure success. Get it now!

You can do drawing with OpenGL ES on a background thread, as long as you do don't try to access the OpenGL context from another thread at the same time. See Apple's Technical Q&A QA1612 for a little more on this.

Up vote 5 down vote favorite 1 share g+ share fb share tw.

In my OpenGL-ES 1.1 based app, I'm using CALayers as a source for OpenGL textures. Those CALayers comprise of CGImages and text rendered through CoreGraphics. Another OpenGL texture source is a screenshot of a UIView taken using -CALAyer renderInContext: and UIGraphicsGetImageFromCurrentImageContext.

Currently, I'm running completely on the main thread. The latter case in particular is pretty bad because it halts the OpenGL rendering for the whole time it takes to create the UIView and its screenshot. Now I'm considering to move the OpenGL code into a separate thread hoping to get around this blocking.

Ideally, the screenshot would be taken on a different thread (main thread if needed) than the OpenGL rendering. I wasn't able to find a complete coverage in the documentation about what requires running on the main thread and what not. I found some comments in the iOS 4 release notes, and some comments in specific UIKit methods but I'm missing the complete picture.

The code runs on iOS 4. X or higher. Iphone multithreading uikit opengl-es core-graphics link|improve this question edited Dec 29 '10 at 17:33genpfault11.4k4918 asked Dec 29 '10 at 17:08Ortwin Gentz5,40031945 93% accept rate.

You can do drawing with OpenGL ES on a background thread, as long as you do don't try to access the OpenGL context from another thread at the same time. See Apple's Technical Q&A QA1612 for a little more on this. I have run into a number of issues with updating CALayer content from a background thread, so I do any work with layers on the main thread.

Core Animation fires off its animations on a background thread, anyway. I'd never updated anything related to UIKit from a background thread, but some aspects of drawing in UIKit were made threadsafe in 4.0. David Duncan comments here that drawing to a context is now threadsafe.

In your case, I wouldn't see a problem with running the OpenGL ES rendering on a background thread (perhaps using a serial dispatch queue in GCD to prevent access to the context from multiple threads at once) and then doing your image grabs on another.

Core Animation is generally thread safe, but UIKit and OpenGL ES (on iOS, at least) are not thread-safe. UIKit must only be used on the main thread, and OpenGL ES must be consistently used on a single thread (usually the main thread. ).

– Ortwin Gentz Dec 29 '10 at 18:46 Pure Core Graphics/Quartz can be used on a worker thread, but cannot always cross thread boundaries safely. Anything that uses UIKit (such as the UIGraphics... functions) must still run on the main thread. – Jonathan Grynspan Dec 29 '10 at 18:55 OpenGL is threadsafe, you just can't use the same context on multiple threads or share resources between different contexts unless they're in a sharegroup.

Check out the documentation for EAGLSharegroup (developer.apple.com/library/ios/document...). – Tommy Jul 7 '11 at 3:16 Yes, but I was being simplistic about it. :) – Jonathan Grynspan Jul 7 '11 at 11:56.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions