TimerObject execution time-out error
-
Often, I get an execution time-out error at init with this code:
const var myTimer = Engine.createTimerObject(); myTimer.setTimerCallback(function() { myTimer.stopTimer(); // Execution time-out error on this line // Some code myTimer.startTimer(30); }); myTimer.startTimer(30);
So I get the error where I stop the timer...
The code in between is only animations and reading values (other component or DSP) so nothing strange in here
I always stop the timer before computing anything and reactivate it at the end, I don't know if it is necessary/good practice though. -
You're starting the timer inside the timer callback so it will create an endless loop. Put
Console.print("HELLO WORLD")
after the .stopTimer(); call and you'll see it outputs forever until it crashes. -
@d-healey That the point in fact. I need it to loop forever. Is there another way?
-
@ustk If you need it to loop forever why do you stop the timer?
-
@d-healey Simply because there's something basic I don't understand with timers.
If, for any reason, the code inside is not done within the 30ms, what happens?
This is why I always do that (I'm paranoid) but it might be bad... -
Just start the timer in on init as you have done and remove the stop/start code from inside the timer. This will make it run forever as soon as the plugin is initialized. I suspect that the execution time-out you're getting is caused by something in your
//some code
section, since I don't get that error message when I copy and paste your code. -
@d-healey Thanks, I removed them and don't get the error apparently.
That what I thought at first but the code inside is not twisted so there's no reasonAlthough I noticed something with Hise:
Every time I have a project getting big, Hise behave strangely. I say strangely because it's not 100% the same issue all the time.
Often, at init, I get many warnings at the same time, like component not found and things like that.
I just press F5 and everything's back to normal.
I work, recompile, then sometimes errors again, sometimes it's ok, and sometimes Hise crashes.It's like big projects cause instability. I don't think (I can't be sure of course) that it's because of my code/design. But who knows...
My exports work fine and pass the plugin validation -
@ustk What do you mean by a big project?
-
@d-healey Complex interface and big DSP
-
@d-healey -- hmm OK but I also have a need to run a timer - and to stop it inside the timer and then calc a new "time" and restart the timer.. so simplified example:
const var myTimer = Engine.createTimerObject(); var kounter = 0; myTimer.setTimerCallback(function() { myTimer.stopTimer(); if (kounter == 0) { myTimer.startTimer(30); Console.print("short"); }else{ myTimer.startTimer(200); Console.print("Long"); } kounter = 1 - kounter; }); myTimer.startTimer(30);
How would you do this?
-
I still have the timer issue...
I have a lead though!
The panel can be hidden, and I know hidden panels are not repainted in the background and cause issues...
Investigating... -
@ustk said in TimerObject execution time-out error:
@d-healey Complex interface and big DSP
I haven't done any DSP stuff so this could be causing instability that I haven't experienced.
In you're example the timer effectively won't stop. So you might as well get rid of the
.stopTimer()
call. The call tostartTimer()
(inside the callback) will just change the timer's speed so should work how you want. -
@d-healey said in TimerObject execution time-out error:
@ustk said in TimerObject execution time-out error:
@d-healey Complex interface and big DSP
I haven't done any DSP stuff so this could be causing instability that I haven't experienced.
In you're example the timer effectively won't stop. So you might as well get rid of the
.stopTimer()
call. The call tostartTimer()
(inside the callback) will just change the timer's speed so should work how you want.--ohhhh. riiiight I didnt know I could effectively change the timer length without stopping it - great. Thanks.
-
Every time I have a project getting big, Hise behave strangely. I say strangely because it's not 100% the same issue all the time.
One thing that might cause issues is the compile time-out which fires if you have a lot of stuff to do in the first onInit call. For example loading a lot of audio files might cause the time-out to fire, but if you compile it multiple times, it wents through.
The default is 5 seconds, but you can raise that value if you run against that limit with bigger stuff in the HISE settings (search "Compile Timeout").
-
@Christoph-Hart Yep that's what I thought at first, so I set it to 10sec, but my compile time is about 2sec with the i7...
It's like the scripts compile before the interface is done, because all the errors (in that case) are only "component not found" (sometimes 10-15 components)
I got all scripts in external .js files (about 35 files). Maybe it can be related...Another thing, when I recompile (just F5) in the onInit script it generally works well. But if I'm in a subscript it's a crash 80% of the time (shift-F5 seems more stable though, because I guess it's more like an init sequence). So now I always keep a tab with the onInit opened and I try to compile in that tab even if I work somewhere else. Recompiling in the interface designer works too.
-
@Christoph-Hart It's weird, every now and then I get an execution time out from anywhere in the project. A loop in this script, a timer in that one, another loop somewhere else...
Nothing is related, and it happens with no apparent reason, except that it's when I pass the mouse on a painted panel (a hover redraw the panel and the execution time out points to a loop in the paint routine)... I recompile, it's gone, and 5 minutes later I get another one somewhere else...
Nothing should be twisted in the code, and everything works fine (parts of these scripts are several months old and I haven't modified them)
If you want to test my project I can share the git with you (only if you're interested, I know you have bigger fish to fry ;) )
-
I was thinking... In a panel constructor (same panel 4 times), I have a paint routine. In this paint routine, I have a loop (
i
goes up to 50) to paint a curve out of two values.The question is, what happens if another panel callback is called when the loop of the first one isn't yet done?
I'm thinking of a leakingi
-
@ustk try defining i in each funciton
local i;