web workers

44 views
Skip to first unread message

Maarten Dungen

unread,
Apr 6, 2017, 9:27:48 AM4/6/17
to haste-compiler
Hi all,

I'm running into problems trying to create a web worker with haste. I'm running on 0.5.5.1 and there every compiled file has prepended the line 'if(typeof window === 'undefined') window = global;' in front of the js file. This seems to be fixed (26/8) in the current version of 'lib/rts.js' which seems to prepend 'if(typeof window === 'undefined' && typeof global !== 'undefined') window = global;'. This works when updating my local 'rts.js' file. However, the crypto extension added on 24/11 clearly won't work in case of a web worker. 

Perhaps it could be changed into something like this?

if(typeof window === 'undefined') 
if (typeof global !== 'undefined') 
window = global;
else if (typeof self != 'undefined')
window = self;


Another question related to web workers. Would it be interesting to have a similar interface to web workers as the haste-app client server model? Does it make sense, and perhaps someone is already working on that? It seems neat to be able to call web workers directly and type safe. 

kind regards,

Maarten

p.s. I'm really impressed with the speed of compiled Haste programs. It is about twice as fast as a GHC version of SAPL when loading and saving midi files. It also seems significantly faster than purescript, however, that is somewhat counter intuitive and I would need to do some more testing. Besides, purescript hits a 'out of stack' fairly soon, when trying to load larger midi files. So, I'm quite impressed overall.

Anton Ekblad

unread,
Apr 6, 2017, 9:49:56 AM4/6/17
to haste-compiler
Hi,
thanks for the heads-up about crypto and web workers! The proposed change makes sense; I'll make sure to incorporate it.

As for a Haste.App-like web worker interface, they should be relatively easy to support in the upcoming version[1] similar to how iframe sandboxes are handled (with a bit of abstraction on top of the two incompatible postMessage DOM APIs). In fact, the plan was to include it from the beginning, but then the paper deadline happened (awand we ran out of pages :P) so they had to give precedence to the stuff we really needed to squeeze in.

/Anton

Maarten Dungen

unread,
Apr 12, 2017, 1:23:06 PM4/12/17
to haste-compiler
Hi,

I got this web worker working as a sandbox. However, I'm kind of stuck on how to call the Client from the sandbox. Is there a way to do this?

kind regards,

Maarten
Reply all
Reply to author
Forward
0 new messages