NSProgressIndicator disappears whenever it starts animating

I have an NSProgressIndicator (spinning) that displays fine when it is not animating, but as soon as it starts animating it disappears. However, when I switch the style to a progress bar, it displays just fine, animations and all. Additionally, it reappears when it stops animating, so it is only invisible while it is spinning.

I am new to Cocoa programming, and I have been searching for several hours through my code and online trying to figure out my issue, but I have been unsuccessful. What would cause this issue?

My code is somewhat based on the code from Apple's sample AVSimplePlayer, found here.


ANSWERS:


I encountered this problem today. It turns out that when using spin, the other things that are running in main thread run first. That means, if you have

let progressIndicator // 
progressIndicator.startAnimation(self)
// do tasks
progressIndicator.stopAnimation(self)

The order in reality is

let progressIndicator // 
// do tasks
progressIndicator.startAnimation(self)
progressIndicator.stopAnimation(self)

So you never see the animation. Here is the workaround, stop main runloop a little while, after progressIndicator.startAnimation(self).

let progressIndicator // 
progressIndicator.startAnimation(self)
RunLoop.main.run(until: Date(timeIntervalSinceNow: 0.001))
// do tasks
progressIndicator.stopAnimation(self)

Then everything will be fine. I find this answer here. You can also try other answers there too.



 MORE:


 ? NSProgressIndicator disappears whenever it starts animating
 ? NSProgressIndicator disappears whenever it starts animating
 ? How to position progress spinner inside the title bar of a Mac application
 ? How to position progress spinner inside the title bar of a Mac application
 ? How to position progress spinner inside the title bar of a Mac application
 ? How can I put an editable table view in a tab bar application?
 ? How can I group editable information like in Apple's "Settings" application?
 ? Using Custom Cell for Mac Application
 ? Navigation items for navigation controller in interface builder
 ? Interface builder's not showing the navigation controller's navigation bar inside a UITabBarController