I've been meaning to write this post since I wrote the build system
prospects post, I just didn't know how to word it.
This post is half me laying out prospective work projects (unrelated to
the build system) for myself and half making people aware of near-term
and medium-term threats and potential implications for tasks that others
tackle. So, without further ado:
SpiderMonkey (JS)
Mozilla is currently making a push to eliminate all legacy JS features.
All the syntactic issues I have filed bugs on (save for the legacy
array/iterator comprehension syntax, since I'm not sure what the
thoughts are there); there's a few random library stuff I haven't
touched (e.g., __noSuchMethod__) in part because I don't detect as much
urgency in eliminating said features. Fortunately, we are making very
good progress in converting code (thanks, aceman!) and we could even be
legacy-free before mozilla-central is. :-)
Also important to be aware of is the addition of new ES6 features. The
only major features that have yet to land are ES6 classes and ES6
modules. Classes will probably land in Q1 or Q2 2015, but the timetable
for modules is extremely uncertain (decent chance of not landing in
2015). There's also a minor host of semantic issues with things like let
or destructuring. Both classes and modules are features that I would be
excited to start using.
JSMime and message composition
As I'm sure you're all aware, I'm slowly making progress on JSMime--my
current focus is MIME message building. I have a rough implementation of
nsMsgSend.cpp (the bigger half of the compose/ directory) in JS already.
Once it is made dogfoodable, I'll continue preview development in an
addon and start preparing work to land it on comm-central. The landing
process will likely be protracted: I'm replacing or abandoning ~11,000
lines of C++ code, and I'm also planning on taking the opportunity to do
a cleanup of several compose interfaces (notably nsIMsgSend,
nsIMsgAttachmentData, nsIMsgAttachedFile, nsIMsgComposeSecure will see
MAJOR changes and nsIMsgAttachment and nsIMsgCompFields are likely to
see minor ones). The end result should hopefully be a better-extensible
interface and fix a slew of bugs in the process (e.g., some of our
questionable decisions with attachments).
Other JSMime
Post-message composition, the next phases of JSMime work will consist of
EAI/IDN support and basic body/attachment support, in some order. The
latter will probably land as just a parser interface with only basic
attachments and multipart/alternative support enabled;
multipart/related, uuencode, yEnc, S/MIME, PGP, and TNEF support will
come later (and probably in that order [S/MIME and PGP come later
because crypto is harder to integrate]). My preview extension for
message composition (see last paragraph) will also start containing
dogfood support for displaying messages via JSMime instead of libmime.
Landing estimates are unavailable at this time.
SMTP?
The recent discussion of IMAP CONDSTORE has made me come to the
realization that, without dedicated developers, our backend is
increasingly lagging in taking advantage of effective new features. One
obvious solution is to start exploring the use of existing JS libraries
for email, such as those on
emailjs.org. The first step is looking at
the SMTP client partly because it's small and self-contained within
Thunderbird (~4000 lines of code with an interface that largely consists
of "send this file to these people using this server and tell me when
it's done") and partly because I have a few feature additions I wanted
to explore anyways (e.g., EAI support, or moving SMTP to a worker
thread). I have already preliminarily looked at the smtpclient.js code
and can assert that it both fails some of our design principles (e.g.,
it uses callbacks instead of promises) and would constitute a regression
to use as-is (barely any support for SASL auth, no non-EAI IDN support,
and no support for DSN. Not sure how it handles non-UTF-8 bodies). I'm
planning on reaching out to the community of users there to see if some
kind of accommodation can be had.
Doing things in workers??
Two question marks this time. Off-main-thread I/O has been a stated
desire of the Firefox performance time for a long while. Considering our
nominal commitment to using more things in JS, this implies that we
should be looking at using workers in Thunderbird code. The difficulty,
though, is that workers have an emasculated API; in particular, there's
no support for XPCOM components and limited support for other features,
even in ChromeWorker threads. We also have an internal design model
which heavily discourages doing things on workers: the message database,
and the message store to a lesser extent, are inherently main-thread only.
I've talked in the past about what it would take to move to an
asynchronous message database. More recently, I've started to sketch out
what an API of an asynchronous message database ought to look like. With
a few tweaks to the current codebase, it is possible to envision
starting to use this API in worker threads. (When you have an
asynchronous API, the fact that everything would get proxied to the main
thread for the current implementation is easy to hide). Unfortunately,
there is one key difficulty: the message database relies heavily on
listeners, and effecting listeners cross-workers is difficult as Workers
are currently implemented.
Using TCPSocket in worker threads is a goal, and once it lands we might
want to start investigating using it where appropriate (e.g., NNTP and
POP). The interface I want to see land before attempting to use the
database off-main-thread is MessagePort (effectively, this allows
generic cross-thread communication), which is currently undergoing
review and will hopefully land in a few months. I'll point out that
IndexedDB-in-workers landed last December. Another complication with
worker threads is that importScripts acts like the subscript loader
instead of Components.utils.import, which suggests that some sort of
require.js-like loader (or ES6 modules, but see above) would be
advisable before using workers too heavily. I have not yet fully worked
out how to deal with cross-thread accesses to the message store, which
makes prospectively porting things like import code to workers difficult.
Thoughts/comments/flames/questions/concerns?
--
Joshua Cranmer
Thunderbird and DXR developer
Source code archæologist