W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2012

Re: Recent Sync XHR changes and impact on automatically translated JavaScript code

From: Olli Pettay <Olli.Pettay@helsinki.fi>
Date: Tue, 20 Mar 2012 18:31:45 +0200
Message-ID: <4F68B0F1.2060508@helsinki.fi>
To: Gordon Williams <gw@pur3.co.uk>
CC: public-webapps@w3.org

On 03/20/2012 06:09 PM, Gordon Williams wrote:
> Hi,
>
> I recently posted on
> https://bugs.webkit.org/show_bug.cgi?id=72154
> https://bugzilla.mozilla.org/show_bug.cgi?id=716765
> about the change to XHR which now appears to be working its way into
> Mainstream users' browsers.
>
> As requested, I'll pursue on this list - apologies for the earlier bug
> spam.
>
> My issue is that I have WebGL JavaScript that is machine-generated from
> a binary file - which is itself synchronous. It was working fine:
>
> http://www.morphyre.com/scenedesign/go
>
> It now fails on Firefox (and shortly on Chrome I imagine) because it
> can't get an ArrayBuffer from a synchronous request. It may be possible
> to split the execution and make it asynchronous, however this is a very
> large undertaking as you may get an idea of from looking at the source.
>
> My understanding is that JavaScript Workers won't be able to access
> WebGL, so I am unable to just run the code as a worker.
>
> What options do I have here?
>
> * Extensive rewrite to try and automatically translate the code to be
> asynchronous
> * Use normal Synchronous XHR and send the data I require in text form,
> then turn it back into an ArrayBuffer with JavaScript
>
> Are there any other options?
>
> Right now, #2 is looking like the only sensible option - which is a
> shame as it will drastically decrease the UX.

#1 sounds like the only reasonable option.
You have now code like:
...
var x = new XMLHttpRequest();
x.open(...);
x.send();
...do something with x.response.


Why couldn't async work?

...
var x = new XMLHttpRequest();
x.open(...);
x.onload = function () { ...do something with x.response. }
x.send();

If you need to prevent user events while XHR is active, put some 
transparent overlay over the page.
If timers shouldn't run, wrap setTimeout with your own stuff which can
suspend timers when XHR is active.



-Olli





>
> - Gordon
>
>
Received on Tuesday, 20 March 2012 16:32:30 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:50 GMT