Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6991239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:28:17+00:00 2026-05-27T19:28:17+00:00

I’m working on a web app that displays (and highlights) music notation as a

  • 0

I’m working on a web app that displays (and highlights) music notation as a song plays. Unfortunately, setInterval falls short of expectations as it’s highly unreliable and skippy, even on relatively low redraw resolutions.

See this demo – all I’m doing is ‘activating’ a bar every x msec, and some of the blocks skip. It might not be bad on fast PCs, but once actual work is done in the loop, it will definitely fall apart.

I’m looking for a solution that will let me run a ui redraw reliably and quickly, without the unacceptable delays. If it helps, the HTML5 audio element is the master node, and all the data will be pulled from it during playback (i.e. audio.currentTime).

Any suggestions are appreciated – perhaps I’m looking for some sort of javascript threading (that doesn’t seem to exist). No matter if it’s not widely supported, I’m just looking to get the job done on a proof of concept here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:28:18+00:00Added an answer on May 27, 2026 at 7:28 pm

    Your be_busy function doesn’t actually ever enter the while loop to be busy for 100 ms. You need to flip the < to a > or >=. So those skips are just from delays in your browser getting a bit behind on the timing. But in reality those delays are insignificant if you have a proper busy function. If you flip the sign you’ll get this: http://jsfiddle.net/Paulpro/PvQFh/40/embedded/result/

    It is expected that it will skip over blocks like that because Javascript is single threaded. So your first call to refresh_ui will occur after 50 ms. Your next after 100 ms. And you should see the first two blocks set active.

    Then at 120 ms, be_busy is called and it holds the thread for 100ms. so refresh_ui cannot be called (whether you use setTimeout or setInterval doesn’t change this fact) until 220ms. refresh_ui will be called at 220 and you’ll see the third block set active. Then at 240 ms be_busy will be called again. So the next refresh_ui cannot occur until 340 ms. When it does occur the 5th block will be set to active in (340/80 = 4.x).

    The fourth block being skipped is expected behaviour in the best browsers. A browser which doesn’t skip that block is probably lagging behind even more.

    So you should have the first three blocks coloured then a a white box then 2 red ones then a white etc. and every 10 groups of two red blocks there will be a single white block.

    The only real way around this is to split be_busy up into a bunch of smaller functions that split the job into pieces, or use Web Workers to do your background (busy) processing, but Web Workers will only work in very recent browsers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.