Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Passing Rust types through the layers IPC boundary.

22 views
Skip to first unread message

Emilio Cobos Álvarez

unread,
Oct 26, 2019, 10:13:54 AM10/26/19
to dev-te...@lists.mozilla.org, Boris Chiou, jmuiz...@mozilla.com
Hey all,

Boris is doing some compositor animation work, and part of that work
involves sending some style system Rust types through IPC.

Some of them are projected to be changed substantially in the near
future, so I suggested to use derive + Serde instead of rolling our own
serialization code from C++.

Boris' patch looks like this:

* https://phabricator.services.mozilla.com/D50688

There's some comments I've left (we should probably not be using
serde_json, but bincode probably, and we should not assume
deserialization will succeed, that kind of stuff...)

But then I realized that WebRender already needs to solve basically the
same problem. Is there some prior art that we could reuse to not roll
our own stuff?

Does the current approach to implement ParamTraits look reasonable? Is
there something we could do to avoid the double copy? We should probably
use an nsTArray<uint8_t> and move it, but I'm not that familiar with
this code. These types are not big so it may not be a big issue, but...

General feedback on the patch would also be welcome.

Thanks in advance!

-- Emilio

Jeff Muizelaar

unread,
Oct 26, 2019, 11:41:11 AM10/26/19
to Emilio Cobos Álvarez, dev-te...@lists.mozilla.org, Boris Chiou
Yes, WebRender solves a similar problem to this. We accumulate a bunch
of DisplayItems into a vec.
https://searchfox.org/mozilla-central/source/gfx/wr/webrender_api/src/display_list.rs#902
That Vec gets converted into a ipc::ByteBuf which is used to avoid
copies in the ipc layer.

We've also switched from serde/bincode to peek_poke for further
performance, however it sounds your performance needs
are modest so perhaps bincode is sufficient.

WebGPU is also going to be doing something similar so it's worth
making sure our infrastructure is relatively reusable.

This was just a quick description, if you interested in more details please ask.

-Jeff
0 new messages