gecko-dev/third_party
Ben Dean-Kawamura 22d5d42244 Bug 1788306: UniFFI callback interfaces, r=nika
Started callback interface functionality to UniFFI.  Currently this only
supports the async fire-and-forget use case, where Rust queues a JS
function to run, but doesn't wait (or `await`) for the response.

The basic system is:

  - The JS code registers a callback interface handler with the C++
    code.  This handler is responsible for the specifics of invoking the
    callback.
  - The C++ code defines a function to call a JS handler.  Once the JS
    handler registers itself with C++, the C++ registers it's function
    with Rust.
  - The C++ code queues the call to the JS main thread.
  - Because of how UniFFI handles callback interfaces, the C++ code can
    be "dumb".  UniFFI sends a object id, method id, and RustBuffer
    encoding all arguments.  This means C++ doesn't need to care about
    the specific arguments, they get unpacked by JS.

I tried to keep the generated code as simple as possible by moving the
complexity to static code.  For JS this meant writing a generic
`UniFFICallbackHandler` class in the static code that the generated code
constructs.  For C++ this meant the generated code defines a
`UniFFIGetCallbackInterfaceInfo` function that returns a struct with all
the data specific to a callback interface (it's name, the UniFFI
scaffolding init function, etc).  The static code can then define a
generic `QueueCallback` function that looks up the callback interface
info using the interface ID and then makes the call.

Allow UniFFI functions to run on the main thread rather than always
being dispatched to a worker thread.  This allows us to test invoking
callback interfaces from the main thread thread. I don't think we will
use this much currently, since we don't want to block the main thread
for any significant amount of time. However, this will pair well with
the next step in the project which is async -- allowing async Rust
functions to call async JS functions. In that scenario, dispatching to
the worker thread is unnecessary.

Callback interface objects present a potential memory leak, since you
can easily create a cycle between a JS Callback object and a UniFFIed
Rust object, and the GC has no way of detecting it.  To try to detect
these there's some shutdown code that checks that there are no callbacks
registered during shutdown and prevents any future callbacks from being
registered.

Added a `config.toml` file and code to parse it.  This is needed to
specify which functions should run on the main thread.

Updated the git commits for the several UniFFI examples/fixtures.

Differential Revision: https://phabricator.services.mozilla.com/D156116
2022-12-14 21:50:23 +00:00
..
aom
cups
dav1d Bug 1800912 - Update libdav1d to revision 4b9f5b704. r=media-playback-reviewers,alwu 2022-12-01 10:44:20 +00:00
function2 Bug 1800927: Fix the Updatebot linter and offending moz.yaml files r=ahal,webdriver-reviewers 2022-11-21 19:35:16 +00:00
googletest
highway Bug 1793238 - Update libjxl r=tnikkel 2022-10-06 17:31:29 +00:00
intgemm
jpeg-xl Bug 1800284 - Update libjxl r=tnikkel 2022-11-15 00:34:56 +00:00
js
libsrtp Bug 1792069: Add libsrtp to Updatebot r=bwc 2022-10-18 15:15:48 +00:00
libwebrtc Bug 1451394 - Record video frame captures with PerformanceRecorder in the new mac camera backend. r=padenot 2022-12-12 15:47:23 +00:00
msgpack
pipewire Bug 1776935 - Update pipewire headers;r=mjf,stransky 2022-08-30 11:04:03 -04:00
prio
python Bug 1799129 - Set glean_parser version to 6.3.0 in requirements.in and version + hashes in requirements.txt to match what is vendored r=janerik 2022-11-09 19:25:13 +00:00
rlbox
rlbox_wasm2c_sandbox
rust Bug 1788306: UniFFI callback interfaces, r=nika 2022-12-14 21:50:23 +00:00
sipcc
sqlite3 Bug 1805507 - Add missing sqlite3 symbol. r=firefox-build-system-reviewers,nalexander 2022-12-14 00:50:15 +00:00
wasm2c Bug 1793734 - update wasm2c to fix wasi stub definitions r=glandium 2022-11-29 22:53:35 +00:00
webkit/PerformanceTests
WinToast Bug 1800927: Fix the Updatebot linter and offending moz.yaml files r=ahal,webdriver-reviewers 2022-11-21 19:35:16 +00:00
moz.build