[whatwg] [canvas] request for {create, get, put}ImageDataHD and ctx.backingStorePixelRatio

Tim Streater tim at clothears.org.uk
Mon Apr 16 13:40:00 PDT 2012


On 16 Apr 2012 at 19:07, Darin Fisher <darin at chromium.org> wrote: 

> Aren't we missing an opportunity here?  By giving web developers this easy
> migration path, you're also giving up the opportunity to encourage them to
> use a better API.  Asynchronous APIs are harder to use, and that's why we
> need to encourage their adoption.  If you just give people a synchronous
> version that accomplishes the same thing, then they will just use that,
> even if doing so causes their app to perform poorly.
>
> See synchronous XMLHttpRequest.  I'm sure every browser vendor wishes that
> didn't exist.  Note how we recently withdrew support for synchronous
> ArrayBuffer access on XHR?  We did this precisely to discourage use of
> synchronous mode XHR. Doing so actually broke some existing web pages.  The
> pain was deemed worth it.

In my app I have about 90 async XMLHttpRequest calls. I have one synchronous one that I'd really like to keep as it facilitates a clean tidy up if the user ignores my Exit button and quits by closing the window. When the app closes I need to run a script in order to shut down a local apache instance amongst other things. I hope I'm not going to find this to be a problem if synchronous mode XMLHttpRequest is removed from Safari at some future point. My code looks like this:


function quitbyClose ()
     {

     // User clicked window close button. Must make a synchronous ajax call to tidy up. We have to ensure
     // SESE with no "return" being executed due to the odd way that onbeforeunload operates, in two cases:
     // 1) Where Safari re-opens myapp after user quits Safari and user has already restarted myapp
     // 2) Where user might try to start this file by hand

     var  request, data;

     if  (portnum>0)
          {

          closeWindows ();                                                      // Close any popups

          data = "datarootpath=" + encodeURIComponent (datarootpath) + "&debugfl=" + debugfl;

          request = new XMLHttpRequest ();
          request.open ("POST", "http://localhost:" + portnum + "/bin/myapp-terminate.php", false);
          request.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); 
          request.onreadystatechange = function() { if  (request.readyState!=4)  return false; }
          request.send (data);

          }

     }


--
Cheers  --  Tim


More information about the whatwg mailing list