Now that central is on Fx69, I will be landing a series of patches making
changes to IPC actor lifecycles which aim to make actors more predictable &
easier to work with.

Here's a short summary of the changes coming down the pipe:

   1.
*mIPCOpen is no longer necessary (bug 1540731
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1540731>) *Actors now
   directly provide two methods: *CanSend()* and *CanRecv()*, which can be
   used to check whether the actor is able to send/receive messages. Most uses
   of a manual *mIPCOpen* member should no longer be necessary, and can be
   replaced.
   Currently, these methods usually return the same value, but future IPC
   features for async actor destruction may allow them to diverge.
   2. *Messages sent to dead actors are discarded (bug 1547085
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1547085>)*
   Previously, if a message was sent over a managed actor which itself was
   sending a *__delete__* message in the other direction, a crash would
   occur, due to the message's target actor being dead when the message is
   delivered. This will no longer cause a crash, and instead the message will
   be discarded, and a warning will be logged in DEBUG mode. This brings the
   behaviour more in line with toplevel actors, which may discard messages
   during shutdown.
   3. *Calling Send*() on a !CanSend() actor no longer crashes (bug 1548717
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1548717>)*
   The send method will now return a `false` value to indicate failure, and
   the message will not be sent.
   4.
*"Well Behaved" actors will be kept alive during Recv* callbacks (bug
   1540731 <https://bugzilla.mozilla.org/show_bug.cgi?id=1540731>) *A "Well
   Behaved" actor here is one which allows IPC to control its lifecycle by not
   being destroyed before the corresponding *Dealloc* method is called.
   This should include most actors, although there are some poorly behaved
   actors which will need to be modified in follow-up bugs. In general, if
   there's no way your actor's allocation will be freed before
   *DeallocPMyActor* is called on its manager, it is a "Well Behaved" actor.
   If a *Recv** callback is on the stack, IPC will delay calling
   *DeallocPMyActor* until after that method has returned. In addition, IPC
   will attempt to keep an actor's *Manager()* alive using the same
   mechanism until after the actor itself no longer has any references from
   within IPC.
   Unfortunately, the *Manager()* method may still return a dangling
   pointer after IPC no longer holds a reference to it, although I hope to
   improve this situation in the future.
   5. *ParamTraits<> specializations for refcounted types have been
   simplified (bug 1547218
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1547218>)*

We plan to continue to improve IPC, adding ergonomics features such as a
special *refcounted* attribute for protocols, which will allow IPDL to
implement "Well Behaved" lifecycle management correctly and automatically.
Feel free to reach out if you encounter additional pain-points with IPDL or
IPC in general. Not all problems necessarily have (simple) solutions, but
it's always good to keep them in mind!

Thanks,
Nika
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to