• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Coalesced updates = pain
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Coalesced updates = pain


  • Subject: Coalesced updates = pain
  • From: John Stiles <email@hidden>
  • Date: Fri, 22 Jul 2005 16:35:42 -0700

I have an app with a large (full-window) custom NSView subclass. This view has some parts that continuously animate, in a loop. The animating parts are quite small, but in many cases they happen to be at the far corners of the NSView.

Back in the OS X 10.2 days, I was profiling it with Quartz Debug and I found that when two far-off sections would want to update at the same time, my code would do this (well, this is a little simplified, but you get the gist):
[self setNeedsDisplayInRect:&firstRect];
[self setNeedsDisplayInRect:&secondRect];
// more rectangles as necessary


I found that the OS would silently merge these two tiny rectangles into one humongous rectangle that covered a large chunk of the screen. Then when my -drawRect got called, it would go and redraw a big rectangle full of content, which used a lot more CPU than necessary.

As a workaround, I found that the following would do what I wanted:
                [self displayRect:&firstRect];
                [self displayRect:&secondRect];
// more rectangles as necessary

And I got just the rectangles that I wanted to draw, and not the union of all my rectangles. This worked well for me in the past, when I was building with CodeWarrior. Now, on the other hand, I have just transitioned to Xcode and started building under 10.4.

Apparently this Xcode-based rebuild has now enabled Coalesced Updates in my app. I found that my animations started getting herky-jerky, despite very low CPU usage. It appears that I'm getting one - displayRect per screen update. So if four things are animating, they are capped to 15fps. As a test, I brought back the - setNeedsDisplayInRect code (which I still had, just commented out), and this solved the herky-jerkiness, but it brought back the original problem where it updated more screen area than necessary. On my dual-1.8GHz G5, this was actually not a very big deal :) ... but I would still prefer to keep the update rectangle as small as possible, since not all of my customers have dual G5s.

What can I do to update the screen fluidly without redrawing way more screen area than necessary?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: Coalesced updates = pain
      • From: Corbin Dunn <email@hidden>
  • Prev by Date: NSImage question
  • Next by Date: Re: Coalesced updates = pain
  • Previous by thread: Re: CoreData - isDeleted behavior question
  • Next by thread: Re: Coalesced updates = pain
  • Index(es):
    • Date
    • Thread