emulator can't handle multithreading

Member
Posts: 64
Joined: 2008.10
Post: #1
I have an opengl game that renders from a seperate thread. This works fine on the device, but on the emulator it takes a whole second to render each frame. Could this be a bug in the emulator?
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
A very important distinction to make: The iPhone simulator is not an emulator. It essentially runs your iPhone application as a Mac application in a very thin wrapper that makes it appear to be running in an iPhone OS-like environment. Consequently, any OpenGL rendering is done natively and will have the characteristics of OpenGL on the Mac, which will have very different performance constraints.
Quote this message in a reply
Member
Posts: 64
Joined: 2008.10
Post: #3
a) it is an emulator.
b) did you even *read* my post? From the sound of it you didn't.
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #4
He gave you absolutely 100% correct information and you were rude.

Behave yourself or lose your ability to post.
Quote this message in a reply
Member
Posts: 64
Joined: 2008.10
Post: #5
I wasn't being rude. The guy didn't even read my post. He posts the same answer everytime somebody mentions the emulator.
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #6
He read your post and he answered correctly.

If you are unable to grasp what he means when he says this, then you should humble yourself and ask for clarifications on the details you do not understand.

Contradicting fact when someone is trying to help you is rude, regardless of whether you think it is or is not.
Quote this message in a reply
Moderator
Posts: 508
Joined: 2002.09
Post: #7
Dude, just chill OK?

First, the iPhone SIMULATOR is not an emulator, hence the name.

Second, running any OpenGL app on the simulator will use the resources of your Mac, so don't be surprised if it runs slow on the iPhone. Because that device has fewer resources, like memory.

Read about how you can optimize gl calls. One tip is to render all your graphics in one call with glDrawArrays or similar.

"When you dream, there are no rules..."
Quote this message in a reply
Moderator
Posts: 450
Joined: 2003.08
Post: #8
Taxxodium: Well, he was saying it runs fine on the device, but slow on the simulator.
However, ThemsAllTook was still right in that there are different factors for each, so just testing on the device is the best idea. If it runs fine on the device, don't worry about the simulator Smile.
Alex

Edit: On a random note, doesn't apple reccomend (pretty much require) that all graphic stuff be done in the main thread? Or is that only for UIKit stuff?
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #9
ThemsAllTook Wrote:Consequently, any OpenGL rendering is done natively and will have the characteristics of OpenGL on the Mac, which will have very different performance constraints.

Not exactly true, it is a software based renderer. From the SDK documentation:
Quote:It is important to understand that rendering performance of OpenGL ES in Simulator has no relation to the performance of OpenGL ES on an actual device. Simulator provides an optimized software rasterizer that takes advantage of the vector processing capabilities of your Macintosh computer. As a result, your OpenGL ES code may run faster or slower in OS simulator (depending on your computer and what you are drawing) than on an actual device. You should always profile and optimize your drawing code on a real device and never assume that Simulator reflects real-world performance.

And not to beat a dead horse, but it really is a simulator, and there really is a technical distinction between the two. As themsalltook pointed out, it's actually running the code natively on your Mac while providing an API that looks like the iPhone's API but performing nothing like it. I'm sure Apple chose to use a software renderer because they didn't want to run into issues where you are mixing and matching features or behaviour of the native GPU and the iPhone's GPU.

As to your actual question about why this is slow, so that you can better test on the simulator: have you tried running Shark to find out where all the CPU time is spent?

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 64
Joined: 2008.10
Post: #10
No one expects that the emulator should be the same speed as the device, but if it's running at one frame per second, then the emulator is effectively useless! An that's my problem. The answer given seemed to be unrelated to my problem.
I'm sorry if I offended anyone.
Quote this message in a reply
Member
Posts: 446
Joined: 2002.09
Post: #11
OK, I'll bite... The previous answers are related to your problem, but you seem to be ignoring the main point...

The simulator is not a device, it's not even an emulation of a device and it does and will behave differently than a device. Sometimes the simulator is faster, sometimes it's slower, sometimes it crashes, sometimes it does unholy crap like you've described. If you think you found a bug with the simulator then you should file a bug report with Apple.

Bottom line: There's not much point trying to fix your code to run better in the simulator. If you want to make a robust iOS game you have to test on devices - lots of devices. The simulator can be a handy tool but it's not a critical component - pretend it doesn't exist and you'll be fine. Cool
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #12
captainfreedom Wrote:I'm sorry if I offended anyone.

No big whoop. Internet communication is very cold and impersonal. Doesn't help that we aren't all from the same country, much less the same state of mind Wink

Folks can't always read and address your post directly on the first pass, and so it is often better to respond with what little other relevant information someone may have. In this case, it was pretty good information that ThemsAllTook gave you to help you look in a different direction to solve the issue. Honestly, if you gotta be mad at someone, he's the wrong guy to be mad at.

Final point: It is in fact a simulator, not an emulator. As has been said a whole bunch already, that is part of your problem, even though it doesn't address it directly. Wink No need for me to repeat the details.
Quote this message in a reply
Member
Posts: 64
Joined: 2008.10
Post: #13
Well, I appoligise once again if I got a bit testy. I guess there is no solution to the problem.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #14
Again, have you tried running shark? It might tell you that there is a trivial issue making you use so much CPU.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  emulator slow when rendering from a second thread captainfreedom 1 2,939 Jan 30, 2010 05:05 PM
Last Post: ChrisD
  Handle input with opengl es melobrien 0 2,124 Oct 24, 2009 07:37 AM
Last Post: melobrien
  How to handle entity rendering MikeD 24 8,667 May 14, 2009 07:50 AM
Last Post: warmi
  iPhone Emulator / Leopard Questions Nick 6 5,490 Aug 8, 2008 11:02 AM
Last Post: Nick