Thanks for the reply Blake...
On 4/24/2015 5:26 PM, Blake Kaplan wrote:
> Hello,
>
>
moz-...@rxv.me wrote:
>> On the other hand, I'm the author of Snap Links Plus and I have not
>> moved on e10s compatibility yet because I'm just not sure the best way
>> to implement it.
> I don't think there's a "best way" to do this. Conversion to multiprocess is
> more of an art than a science. Here are a couple of tips, that may help.
>
>> Per my understanding of e10s, each document will either be its own
>> process or served by some pool of processes.
> This is right. At the moment (and for the foreseeable future) the process
> boundaries are going to be per-tab at their most granular. We might eventually
> want to put things like cross-origin iframes in their own processes, but that
> is pretty far out.
>
>> I could implement *nearly* all of SnapLinksPlus in the document, but
>> this seems as though it would cause each document to bloat
>> un-necessarily. This would be the case unless I only loaded a stub
> I'm not sure what bloat you're worried about, exactly. We already load several
> megabytes worth of code in both the parent and the child, so a bit of extra
> code won't matter too much. Even with several copies, the extra memory used
> for your addon should be dwarfed by the memory used by the system.
Okay, I won't worry about that too much then, my goal is responsiveness
but without overburdening for no reason.
> That being said, it looks like you're going to have to do some splitting
> between the parent and child anyway. The context menu has to be opened by the
> parent process, while the DOM manipulation should take place in the child. So,
> I would expect the code that handles the mousedown/mousemove/mouseup events
> and that calculates what links are in the given rectangle to live in the child
> process and then to send a message to the parent with the information needed
> in order to display the context menu. The context menu would then probably
> want to send a message down to the child in order to navigate (or something to
> that effect, if you have to open new tabs then you'd probably want to just
> pass the URL up).
>
> Does that make sense? Concretely, the code in the parent could live in a
> module or overlay and use the message manager to create a delayed frame script
> (only one per startup) and then communicate with that script.
I think it makes the most sense to put it in the document, however I had
thought of another issue I probably have no way to solve which is that
SnapLinks does quite a bit of work to make iframes transparent to the
user, meaning that if there are one or many iframes in a document and a
drag is started which drags over the main document and two or three
iframes, it will highlight and function on those iframe links as though
they were not in an iframe.
This trickery is only accomplished because the XUL side (used to be able
to) traverse the DOM without security restrictions. Will I have to
somehow inject code into each iframe as well and have those segments
communicate to... the outer document? (don't think that's possible),
to... the XUL code and then back down to the main document?
>> On the other hand, I could implement it entirely on the XUL side, but
>> this would seem to defeat the purpose of multiple processes (as I
>> understand that the XUL side will still be a single process?)
> This is an excellent point. As a matter of fact, we do have CPOWs, which allow
> the parent process to synchronously talk directly to DOM nodes in the child;
> however, doing so does, in fact, defeat the purpose of using multiple processes and
> cause it to jank (and the jank would be even worse because now there's
> additional IPC overhead).
That makes sense, but with a UI type of interface, responsiveness seems
to be the driving goal, I don't think the async nature should a problem,
in fact the multi-process aspect will probably improve responsiveness if
I offload calculations (which I'd been considering doing anyway to a web
worker). Like many (I hope) I do not have much experience with multiple
threads of execution but have done it before with success.
> I hope this helps.
I does and gives me some impetus to get my butt in gear soon, thanks!