Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6763873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:31:42+00:00 2026-05-26T14:31:42+00:00

I know this question has been asked before, but no one has given any

  • 0

I know this question has been asked before, but no one has given any helpful answers as to how to fix it. I have a cocos2d ios application that uses the box2d physics engine. I ran a performance test on it and the cpu spends 5.6% of its time on mach_msg_trap. From what I have gathered from other questions, it seems as if mach_msg_trap is just the main thread waisting time as a result of your application being idle. My application isn’t idle though. It has shaky performance and hovers in the 50 fps area. Is there some way to configure this to gain extra performance? Or is this just a result of some bad code i wrote and if so how do I optimize it?


I am testing the performance in the debug build on an ipod touch second generation. This might be part of the problem. I am grouping certain things in sprite batches. But some sprites have children that aren’t ccsprites so I can’t group everything in one single batch. I do create a pool of bullets instead of allocing and releasing them constantly. But this is where I get the shaky performance. When a gun starts firing the framerate drops 10-15 fps. I tried to track what was taking so long using instruments but the top two time waisters are glValidateState, which includes ccsprite draw and ccnode visit. The second beggest time waister is mach_msg_trap. Is there any other way to find out what it is in the bullet’s code that is slowing the performance down? By the way your book was really helpful in learning cocos2d:)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:31:42+00:00Added an answer on May 26, 2026 at 2:31 pm

    Have you read the answer to this question?

    mach_msg_trap is not wasting time being idle. It’s a function that waits for some result before the application’s process can continue with normal execution. Of course it will also run when your app is idle, but I doubt that this is the case for you. Instead those 5% may come from waiting for disk I/O for example when loading a file from flash memory.

    If your performance is “shaky” I wouldn’t waste time trying to find the fault in system level functions that you can’t modify or configure.

    Secondly, you haven’t mentioned where you are measuring the performance, ie which device. If you get 50 fps on an iPhone 3G or older the performance could even be considered good. In addition you should measure performance only in release builds.

    Personally I can only recommend to check that you’ve followed best practices, like using sprite sheets and a texture atlas for your sprites, pooling sprites and physics objects instead of creating and releasing them frequently, and reducing the number of iterations Box2D is running in its step function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question has been asked before, but none of the previous answers
I know this question has been asked before, but this was one and a
I know this question has been asked before but I seem to have a
I know this question has been asked before but I have a design question
I know this question has been asked before, but many answers don't give clear
I know this question has been asked before, but I ran into a problem.
I know this specific question has been asked before , but I am not
I know this question has been asked a bit before. But looking around I
I know this question has been posted before... but I haven't found any answer
I know this question has been asked before and I read all the answers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.