hackpad icon indicating copy to clipboard operation
hackpad copied to clipboard

Run processes in web workers, use message passing for orchestration

Open JohnStarich opened this issue 3 years ago • 9 comments

Closes https://github.com/hack-pad/hackpad/issues/11

This is currently a huge refactor and a work in progress. Hopefully will suss out the major bugs soon 😅

JohnStarich avatar Oct 11 '21 06:10 JohnStarich

I have been working on exactly the same thing myself but you seem to already be way further down the road.

I am using tinygo to compile golang to wasm and then exposing it as a WebWorker. The Dwarf debugging works in the chrome browser which makes it really easy to test your golang . Very promising for those interested in building a IDE or just reusing golang in the Browser .

I am yet to pull this PR to try it out . I saw the latest update to go 1.9 too. Nice

gedw99 avatar Sep 29 '22 08:09 gedw99

Hey @gedw99, good to hear on the debugging side of things with tinygo. Mainline Go's support for debugging has been difficult to say the least. I do hope it improves.

This PR is so very close to being ready. Unfortunately, I'm continuing to have setbacks especially with regard to inter-worker communication. The latest build I have (may not be pushed here yet) is doing everything with web workers and works pretty well, but still has some issues with sharing file descriptors over pipes. Until those issues are overcome, I hesitate to merge them in as it would decrease reliability of the currently deployed version.

I'm maddeningly close – only thing holding me back right now is the lack of a useful debugger. Walking through individual Wasm instructions isn't my idea of fun 😅

JohnStarich avatar Oct 02 '22 20:10 JohnStarich

It’s not possible to use tinygo ?

There are pretty easy work around for reflect is that’s the issue.

Here is an example of debugging tinygo wasm with Chrome. It has source maps so you step through actual golang inside chrome.

https://blog.noops.land/debugging-webAssembly-from-go-sources-in-chrome-devtools

You might already know about all the above ?

gedw99 avatar Oct 15 '22 16:10 gedw99

Thankyou for persisting on this. I think a ton of devs doing wasm golang want Web workers but just don’t have time / energy to work it through.

Also there are a ton of disruptive things that can be bunk on top of hackpadfs. Unblocking the gui thread by having the FS in a Web Worker unblocks tons of possibilities !!!

gedw99 avatar Oct 15 '22 16:10 gedw99

Hey @gedw99! If it takes much longer, I may need to try tinygo instead. I'm feeling the sunk-cost fallacy pretty strongly right now 😂 It at least appears I'm close to done. There's some message passing issues (messages showing up out of order or duplicated) but that's essentially all I can see remaining.

Thank you for your words of encouragement ❤️

JohnStarich avatar Oct 23 '22 03:10 JohnStarich

hey @JohnStarich how is this going?

amlwwalker avatar Jan 25 '23 19:01 amlwwalker

Hey @amlwwalker, thanks for checking in. Not swiftly, unfortunately. Probably will be quite a while yet. I've hit several frustrating brick walls in the process of fixing this up. While I would love to say "going great, almost done", I don't want to give you the wrong idea – this likely won't be done for many more weeks.

Instead of giving up, however, I've been investing my time in fixing everything that's been slowing me down. Recently, I've been tackling the lack of tools for Go + Wasm. Specifically I'm making it possible to write more and higher quality automated tests with improvements to wasmbrowsertest (#41, #42) and Hackpad's underlying libraries (safejs, #8, #31). These are a critical part of my workflow, so hopefully this will be the catalyst we need.

It's very slow going, but I fully intend to root out these impossible-to-debug failures I'm hitting on this PR eventually!

JohnStarich avatar Jan 26 '23 03:01 JohnStarich

hi @JohnStarich looking forward to seeing this exciting work proceed. is there anything that I can help contribute to?

paralin avatar Mar 21 '23 03:03 paralin

@JohnStarich

like @paralin said - if i can help please shout :)

gedw99 avatar May 16 '23 10:05 gedw99