Cephalopod
Cephalopod copied to clipboard
Prevent fade from freezing with the main thread
Before this change the Timer
would run on the main thread, meaning if your UI froze, so did the audio fade. Grand Central Dispatch allows it to run on a background thread as well run much more efficiently.
This simply converts AutoCancellingTimerInstance
to use DispatchQueue
instead of Timer
.
Hi @thecodewarrior, thanks for contributing. A couple of small issues I noticed
-
Most importantly, the is a hiccup in the music when I launch the demo app. The sound is interrupted with a small period of silence.
-
It shows "Main Thread Checker: UI API called on a background thread: -[UIView setHidden:]" error in the Xcode output window when I run the demo app.
-
The "Fading out..." message in the demo app does not disappear immediately after the fade finishes.
-
I think it will useful to write in the Readme that the finish closures are now called asynchronously.
Let me know if this can be addressed so we can merge this. :)