Hey @lukewagner et al, I've been experimenting with chunked decoding and I have some questions.
My experimental setup is using the onprogress event of XMLHttpRequest for mid-transfer control. This is working well. I suspect WebSockets might be a better way to serve this stuff, but I'm looking at XHR first because it requires less up-front setup (every webserver supports GET, but ws:// takes more work). Anywho, on to the questions.
Currently, the polyfill downloads the complete binary, then unpacks it. Unpacking involves a couple of mallocs and then a call to _asmjs_unpack.
One malloc reserves space for the incoming bytes. No problem here, we've got access to the total bytes as early as the first onprogress event. There's another malloc that has me concerned, though. It reserves space for the unpacked asmjs code, as determined by _asmjs_unpacked_size. Since I'm not sure how that function works, I'm not sure we can malloc that space before the download is complete (how does it know?). Perhaps it uses some theoretical maximum size of asmjs that can be generated by a given number of wasm bytes?
Beyond the mallocs, I need some guidance on how _asmjs_unpack is going to work when unpacking an incomplete binary, a little bit at a time. The incoming binary slices will be at arbitrary positions, so _asmjs_unpack (or a wrapper function) will need to intelligently handle things like partial opcodes, opcode without args, etc. Without source or docs, it's hard to know what to expect.
My questions all boil down to this: what steps should be taken during each onprogress tick? and where can I find source or docs for the _asmjs_* functions?
Hey @lukewagner et al, I've been experimenting with chunked decoding and I have some questions.
My experimental setup is using the
onprogressevent ofXMLHttpRequestfor mid-transfer control. This is working well. I suspect WebSockets might be a better way to serve this stuff, but I'm looking at XHR first because it requires less up-front setup (every webserver supports GET, but ws:// takes more work). Anywho, on to the questions.Currently, the polyfill downloads the complete binary, then unpacks it. Unpacking involves a couple of mallocs and then a call to
_asmjs_unpack.One malloc reserves space for the incoming bytes. No problem here, we've got access to the total bytes as early as the first
onprogressevent. There's another malloc that has me concerned, though. It reserves space for the unpacked asmjs code, as determined by_asmjs_unpacked_size. Since I'm not sure how that function works, I'm not sure we can malloc that space before the download is complete (how does it know?). Perhaps it uses some theoretical maximum size of asmjs that can be generated by a given number of wasm bytes?Beyond the mallocs, I need some guidance on how
_asmjs_unpackis going to work when unpacking an incomplete binary, a little bit at a time. The incoming binary slices will be at arbitrary positions, so_asmjs_unpack(or a wrapper function) will need to intelligently handle things like partial opcodes, opcode without args, etc. Without source or docs, it's hard to know what to expect.My questions all boil down to this: what steps should be taken during each
onprogresstick? and where can I find source or docs for the_asmjs_*functions?