Emscripten, webassembly/asm.js, and taskwarrior

41 views
Skip to first unread message

Mark Scannell

unread,
Nov 15, 2017, 4:22:34 AM11/15/17
to taskwarrior-dev
Hello all --

I've been playing with taskwarrior source code and was thinking about how it'd be great if I could have taskwarrior with me everywhere. Particularly with a Chromebook.

I've been working with emscripten compiling taskwarrior into asm.js and have been successful so far. I have it running in the browser, synchronizing the in-memory files with Google Files, saving them to indexdb, and have a little interactive shell. (using hterm.js) I plan on releasing this as open source at some point. (My employer has a process.)

There's a lot of little nuances, of course, and have had to turn off all confirmation in taskwarrior (no working stdin).

So far I haven't had to make any changes to taskwarrior source code except one somewhat major one: the global context.

In the asm.js context, I use the main() function as if it was a library and keep calling it again and again. This causes issues with the global context being already-initialised.

My solution:
- Remove it as a global, and have a global "registry" of the current context.
- main() has its own context on its stack. It then registers this as the current context when it starts.
- All calls to context gets the "current context".

This has proved remarkably successful, including having all of the tests pass.

So my question:
Would taskwarrior entertain such a patch? Or a patch which would achieve a similar outcome? There may be other more elegant solutions, of course.

This is a bit off-the-wall I realize...

Thanks!
Mark

Thomas Lauf

unread,
Nov 18, 2017, 6:26:19 PM11/18/17
to Mark Scannell, taskwar...@googlegroups.com
Hi Mark,

sorry for the late answer, but can you provide a patch with the changes
you described? It would be easier for me to review your changes then.

Thanks
Thomas
signature.asc

Mark Scannell

unread,
Nov 27, 2017, 1:59:45 PM11/27/17
to Thomas Lauf, taskwar...@googlegroups.com
Thomas,

I've attached the patch.

This is very much a proof of concept -- there are many ways to make this code simpler, more elegant, etc, but I wanted to see if I could make main() usefully re-entrant first. It seems to work. The main problem is that Context is a static global object, so if you treat main() like a library then it will have the constructor but never be destroyed.

If you could give me feedback on the approach of hosting the global context in the Context object as a static with getter/setters, and, if you're happy with that, I could look to make the accessing of context more elegant than just replacing "context" with "Context::getContext()" globally.

I couldn't figure out any other simpler way to manage the state of context as it appears everywhere.

Mark
0001-Updated-to-make-main-re-entrant-new-INSTALL-instruct.patch

Thomas Lauf

unread,
Nov 29, 2017, 3:19:45 AM11/29/17
to taskwar...@googlegroups.com
Hi Mark,

thanks for the patch. I will take a look at it as soon as I find time
for it. Thanks in advance for your patience.

Regards
Thomas
signature.asc

Mark Scannell

unread,
Nov 29, 2017, 3:35:36 AM11/29/17
to taskwar...@googlegroups.com
Thomas,

No rush at all. My day job and rest of life has taken over again!

Mark

--
You received this message because you are subscribed to a topic in the Google Groups "taskwarrior-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/taskwarrior-dev/hiX7nKb6wrA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to taskwarrior-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

scan...@google.com

unread,
Jan 30, 2018, 9:35:23 AM1/30/18
to taskwarrior-dev
Thomas,

Any thoughts?

I'm looking for feedback on the general approach I've taken -- happy to adjust it to something different.

Mark

Paul Beckingham

unread,
Jan 30, 2018, 9:45:21 AM1/30/18
to taskwar...@googlegroups.com
Hi Mark,

I don’t know how I missed this entire thread. I apologize.

The goal is good, the approach is good, the patch will no longer apply, but that’s not a problem because it’s mostly just a big search/replace.

I will take your earlier patch, and do what I can with it, and see what happens. I’ll respond here.

Paul
> --
> You received this message because you are subscribed to the Google Groups "taskwarrior-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to taskwarrior-d...@googlegroups.com.

Mark Scannell

unread,
Jan 30, 2018, 11:29:58 AM1/30/18
to taskwar...@googlegroups.com
Paul,

No worries. Have a look and give me feedback. I'm happy to adapt to the latest source code, rename the search-and-replace, re-apply it, whatever. I just want to ensure any work I do goes in the direction of being a worthwhile patch.

Mark


> To unsubscribe from this group and stop receiving emails from it, send an email to taskwarrior-dev+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--

You received this message because you are subscribed to a topic in the Google Groups "taskwarrior-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/taskwarrior-dev/hiX7nKb6wrA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to taskwarrior-dev+unsubscribe@googlegroups.com.

Thomas Lauf

unread,
Jan 31, 2018, 7:07:02 AM1/31/18
to scannell via taskwarrior-dev
Hi Mark

> Any thoughts?
> I'm looking for feedback on the general approach I've taken -- happy to adjust it to something different.
Sorry, your patch got buried under a lot of other things. I've seen that
Paul has taken over, so maybe he can inform me, when we meet next time :)

Regards

Thomas

signature.asc

Paul Beckingham

unread,
Jan 31, 2018, 1:43:07 PM1/31/18
to taskwar...@googlegroups.com
Sorry Thomas, did I take a fun toy away from you there?

I’ve taken Mark’s patch and munged/applied it to 2.6.0. I made a few more changes, because it was incomplete, and no, all the tests did not pass. The patch in general is a minor step backwards in readability (“context.” becomes “Context::getContext ().”) but for a nice gain. At this point I’m happy to merge my version of the patch.

Mark, will this satisfy all the emscripten needs?

Thanks,

P
> --
> You received this message because you are subscribed to the Google Groups "taskwarrior-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to taskwarrior-d...@googlegroups.com.

Thomas Lauf

unread,
Jan 31, 2018, 5:48:28 PM1/31/18
to taskwar...@googlegroups.com
> Sorry Thomas, did I take a fun toy away from you there?
Nope, somehow (don't ask me how) I thought it concerned TimeWarrior =)
Happy the patch found a home after all...

Thomas

Mark Scannell

unread,
Feb 1, 2018, 4:44:15 AM2/1/18
to taskwar...@googlegroups.com
Paul,

I compiled it and have been running it with just those changes. That should be sufficient.

There are some features that are incompatible with the web environment (eg stdin), but for everything like that so far I've been able to disable it using the normal configuration.

Mark


You received this message because you are subscribed to a topic in the Google Groups "taskwarrior-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/taskwarrior-dev/hiX7nKb6wrA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to taskwarrior-d...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages