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





Reply via email to