I have a bar-style NSProgressIndicator
in a subview of a layer-backed view. Its behavior is sort of complicated, but at certain points, it is displayed as a bar-style indeterminate progress indicator. The problem is, when in this state, it doesn't animate (i.e. twirl the barber pole). Turning off layer backing fixes the issue, but that makes other animations the window does less smooth, so I'm hoping for something better.
Here's the full behavior: when what amounts to a dirty flag is set, it should become visible as an indeterminate, animating progress indicator; then after a short delay (to make sure the user has finished typing) it transforms into a determinate progress indicator and fills as various operations are performed; and finally, at the end of the whole process, it hides itself once more.
To implement this, I've set up the following bindings:
- Hidden is bound to my model's
loading
property with anNSNegateBoolean
value transformer. - Is Indeterminate is bound to my model's
waitingForInput
property. - Value is bound to my model's
currentProgress
property (which is 0 whenwaitingForInput
is true). - Max Value is bound to my model's
maximumProgress
property (which is 0 whenwaitingForInput
is true).
This mostly works, but with one exception: when waitingForInput
is YES
, and thus the progress indicator is indeterminate, the progress indicator doesn't animate .
The usual reason for a progress indicator to not update is that the programmer is blocking the run loop with a long-running operation, but I'm not doing that: during the period in question, the run loop is totally open, with just a timer waiting to fire. As far as I know, it's not in some odd mode, either. The app accepts keystrokes and other events during this time without any issues. (The later phase, with a determinate progress indicator filling up, is driven by an asynchronous NSURLConnection
, so it's not blocking either.)
I've taken several steps to try to fix this problem:
- I've tried setting the Animate binding on the progress indicator to my model's
waitingForInput
property, like Is Indeterminate. This causes the animation to update jerkily when change notifications fire onwaitingForInput
(waitingForInput
happens to send KVO notifications every time the input delay restarts), but I'm hoping for a much smoother animation than that. - I've tried using KVO to observe changes to both
loading
andwaitingForInput
. When a change is observed, it calls the progress indicator's-startAnimation:
and-stopAnimation:
methods as appropriate. These have no apparent effect. - I've tried setting
usesThreadedAnimation
on the progress indicator toNO
. (A hit on Google suggested this might help with updating problems on layer-backed progress indicators.) This has no apparent effect. I also triedYES
, just for kicks, which proved equally futile.
Finally, I've also tried turning off layer backing. This does fix the problem when combined with the Animate binding. However, it degrades the performance of other animations unacceptably, so I'd prefer to avoid doing this.
So, any ideas, anyone? I'd really appreciate some help with this problem!