HISE Logo Forum
    • Categories
    • Register
    • Login

    Inline function triggered by a callback = execution timeout

    Scheduled Pinned Locked Moved Bug Reports
    46 Posts 4 Posters 2.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • LindonL
      Lindon @ps
      last edited by

      @ps well with the paint routine out and then wiht it in:

      Interface: start
      Interface: Benchmark Result: 194.833 ms
      Interface: Compiled OK
      Interface: start
      Interface: Benchmark Result: 193.293 ms
      
      

      Yeah quicker (just) with it in...

      HISE Development for hire.
      www.channelrobot.com

      P 1 Reply Last reply Reply Quote 0
      • P
        ps @Lindon
        last edited by

        @Lindon haha but can you also push it to the same values by raising the number in the loop until you get a timeout?

        LindonL 1 Reply Last reply Reply Quote 0
        • LindonL
          Lindon @ps
          last edited by

          @ps said in Inline function triggered by a callback = execution timeout:

          @Lindon haha but can you also push it to the same values by raising the number in the loop until you get a timeout?

          yep got you -- set the loop to 9000000 works fine with no paint routine, fails with a paint routine:

          Interface: Benchmark Result: 864.576 ms
          Interface: Compiled OK
          Interface: start
          Interface:! Line 30, column 9: Execution timed-out {SW50ZXJmYWNlfHw1MzB8MzB8OQ==}
          extimeout:! Line 30, column 9: Execution timed-out 
          

          HISE Development for hire.
          www.channelrobot.com

          P 1 Reply Last reply Reply Quote 0
          • P
            ps @Lindon
            last edited by

            @Lindon ahh thanks for confirming - I assume that also on your end probably it’s around 300ms with the paint routine (which makes the find files function and other functions that need a bit more time run into timeout)

            So the question is - why does including a paint routine limit the timeout to such a short time when an inline function get’s called through a callback…

            LindonL 1 Reply Last reply Reply Quote 0
            • LindonL
              Lindon @ps
              last edited by

              @ps said in Inline function triggered by a callback = execution timeout:

              @Lindon ahh thanks for confirming - I assume that also on your end probably it’s around 300ms with the paint routine (which makes the find files function and other functions that need a bit more time run into timeout)

              So the question is - why does including a paint routine limit the timeout to such a short time when an inline function get’s called through a callback…

              damn good question..

              I've got it paired down to this and it errors...

              inline function test()
              {
              Console.startBenchmark();	
              Console.print("start");
              
              Console.startBenchmark();	
              for (i=0;i<2050000;i++)
              {
              Math.random();
              }
              Console.stopBenchmark();
              	
              }```

              HISE Development for hire.
              www.channelrobot.com

              P 1 Reply Last reply Reply Quote 0
              • P
                ps @Lindon
                last edited by

                @Lindon which is based on your benchmark before not a very long time probably - I guess this is a case for @Christoph-Hart now :)

                LindonL 1 Reply Last reply Reply Quote 0
                • d.healeyD
                  d.healey
                  last edited by

                  @Christoph-Hart is findFiles synchronous?

                  Libre Wave - Freedom respecting instruments and effects
                  My Patreon - HISE tutorials
                  YouTube Channel - Public HISE tutorials

                  1 Reply Last reply Reply Quote 0
                  • LindonL
                    Lindon @ps
                    last edited by

                    I fiddled around a little more - its in and around the 200ms mark that its failing...sometimes it will make it over 200ms and be OK - but only slightly and very rarely...

                    HISE Development for hire.
                    www.channelrobot.com

                    Christoph HartC 1 Reply Last reply Reply Quote 0
                    • Christoph HartC
                      Christoph Hart @Lindon
                      last edited by

                      Alright, I could reproduce the issue. The thing is that there are different timeout values for different callbacks, so the paint routine eg. has a very short timeout value because it's not expected to take longer than 200ms, and if you're writing a paint routine that takes longer than 200ms you'll need to take a step back and evaluate life decisions that led you to the point.

                      However the timeout is a single value and if you're calling something on another thread (like eg. the server thread), which has a much higher timeout to cope with things like findFiles() etc., it will overwrite the long timeout value with the short paint timeout restriction hence triggering the timeout pretty fast (and scanning 50-100 files quickly exceeds 200ms).

                      The complicated solution would be to make a thread local value for the timeout so that it won't cause problems like this, but actually I think I'll just forget about the entire concept of different timeouts and just use a single reasonable value like 3 seconds everywhere and then call it a day - the only hard reason for a timeout is to prevent

                      while(true)
                      {
                          Math.random();
                      }
                      

                      from freezing your system and the idea of educating people by not allowing their code to run longer than an arbitrary limit isn't worth the hassle of coping with edge cases like this.

                      Christoph HartC 1 Reply Last reply Reply Quote 2
                      • Christoph HartC
                        Christoph Hart @Christoph Hart
                        last edited by

                        Alright, now everything has 5 seconds to complete its task - the only difference is that the onInit callback has a timeout that can be specified in the settings (defaults to 15 seconds).

                        Also I've bypassed the timeout detection for the findFiles() call as this is a call that has a unbounded maximum execution time so you should be able to scan 10 thousands of files without breaking the timeout limit.

                        P 1 Reply Last reply Reply Quote 4
                        • P
                          ps @Christoph Hart
                          last edited by

                          @Christoph-Hart that's perfect. Thank you!

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post

                          17

                          Online

                          1.7k

                          Users

                          11.9k

                          Topics

                          103.4k

                          Posts