I found there is some strange behaviour with Timers.
In my project I use only one
Timer. And it is in
AudioProcessorEditor so as I understand it should work only when my plugin window is opened. And by debuging I found it works as I expect.
But in the Debug Navigator in xCode, under CPU usage I see many timers. Ok, it’s still understandable for me - probably there are more timers in the depth of Juce framework code.
But what is strange for me, two things:
- I can’t see there my
- And - wthat is most strange for me - there is one timer which starts running only after second opening of my plugin window. I mean it doesn’t work when I launch my plugin and open window. It doesn’t work when I close it. And suddenly it start works when I open window again. And from that point (I mean second window opening) it is always running on each windows opening.
It looks like that:
And of course after first open, my Timer works great, it’s just not shown on that window.
It wouldn’t for me big deal, but the problem is my plugin CPU usage is almost doubled when that strange timer start running.
I thought maybe my first timer doesn’t stop running on closing window, so debuger run new instance of Timer every time I open window. But at first, why then that additional Timer is only one and it stops running everytime I close the window. And at second, to be sure my plugin stops timer every time I close the window I call
stopTimer() in the destructor of
AudioProcessorEditor. But it doesn’t help.
So now, I have no idea how to fix that. But as I told it’s important. Because every time that second Timer starts running the CPU usage jumps almost double - from about 30% to about 55%.