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.
    • 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

                29

                Online

                1.7k

                Users

                11.9k

                Topics

                103.4k

                Posts