Convert uses of Rc<Promise> to RootedPromise or TracedPromise
Author: jdmCreated Sep 2, 2026Updated Sep 17, 2026
LabelsA-content/domE-less-complexI-perf-bloat
As discovered in #45262, we leak memory due to how we store Rc<Promise> objects that cannot be GCed inside of our DOM objects that are traced by the GC. #47682 and #47735 give us the tools to fix this problem, and we're going to do it in bite-size pieces.
Common patterns:
TrustedPromise::new(rc_promise.clone())->TrustedPromise::from(rooted_promise)- some method that returns
-> Rc<Promise>becomes-> RootedPromise, and any calls toPromise::new_in_realm/Promise::new_resolved/Promise::new_rejectedget a_rootedsuffix - any webidl method that returns
-> Rc<Promise>needs updating Bindings.conf to removeuseRcPromisefrom that interface - any
#[dom_struct]or#[derive(JSTraceable)]struct containing aRc<Promise>changes toTracedPromise(and remove any#[conditional_malloc_size_of]for that field) - any
Rc<Promise>/&Rc<Promise>in an argument position should be&RootedPromiseor&Promise, whichever is easier
Make sure to build with --use-crown to catch new cases that need extra rooting (possibly adding #[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] and rooting the struct on the the stack).
Please leave a comment claiming files that you will convert. We're not going to assign one single person to this issue because it can be parallelized very effectively.
Infrastructure to convert:
- RoutedPromiseListener (https://github.com/servo/servo/pull/47816)
- WebGPUAdapterResponse (https://github.com/servo/servo/pull/47816)
- AsyncBluetoothListener (#47817)
Files to convert:
- audiocontext.rs (#47872)
- baseaudiocontext.rs (#47872)
- blob.rs
- bluetoothdevice.rs (#47941)
- bluetooth.rs (#47941)
- bluetoothpermissionresult.rs (#47817)
- bluetoothremotegattcharacteristic.rs (#47941)
- bluetoothremotegattdescriptor.rs (#47941)
- bluetoothremotegattserver.rs (#47941)
- bluetoothremotegattservice.rs (#47941)
- body.rs
- byteteereadintorequest.rs
- byteteereadrequest.rs
- byteteeunderlyingsource.rs
- cachestorage.rs
- crendential.rs (https://github.com/servo/servo/pull/48021)
- cache.rs
- clipboard.rs (https://github.com/servo/servo/pull/47816)
- clipboarditem.rs
- cookiestore.rs
- cookiestoremanager.rs
- customelementregistry.rs
- defaultteereadrequest.rs
- defaultteeunderlyingsource.rs
- document.rs
- element.rs
- fakexrdevice.rs
- fetch.rs
- fetch/fetch.rs (#47954)
- fullscreen/lib.rs
- fontface.rs (#47935)
- fontfaceset.rs (#47935)
- gamepadhapticactuator.rs
- globalscope.rs
- gpu.rs (https://github.com/servo/servo/pull/47816)
- gpuadapter.rs (https://github.com/servo/servo/pull/47816)
- gpubuffer.rs (https://github.com/servo/servo/pull/47816)
- gpudevice.rs (https://github.com/servo/servo/pull/47816)
- gpuqueue.rs (https://github.com/servo/servo/pull/47816)
- gpushadermodule.rs (https://github.com/servo/servo/pull/47816)
- htmlimageleement.rs
- htmlmediaelement.rs
- idbfactory.rs
- imagebitmap.rs
- mediadevices.rs
- module_loading.rs
- navigationpreloadmanager.rs
- notification.rs
- offlineaudiocontext.rs (https://github.com/servo/servo/issues/48051)
- offscreencanvas.rs
- permissions.rs (#47941)
- promiserejectionevent.rs (#47954)
- readablebytestreamcontroller.rs (#47909)
- readablestream.rs (#47909)
- readablestreambyobreader.rs (#47909)
- readablestreamdefaultreader.rs (#47909)
- readablestreamgenericreader.rs (#47909)
- request.rs
- response.rs
- rtcpeerconnection.rs
- rtcrtpsender.rs
- serviceworkercontainer.rs
- serviceworkerregistration.rs
- servointernals.rs (https://github.com/servo/servo/pull/47816)
- storagemanager.rs
- subtlecrypto.rs
- testbinding.rs
- testutils.rs
- testworklet.rs
- transformstream.rs (#47909)
- transformstreamdefaultcontroller.rs (#47909)
- wakelock.rs (https://github.com/servo/servo/pull/47816)
- webglrenderingcontext.rs (https://github.com/servo/servo/pull/48022)
- webgl2renderingcontext.rs (https://github.com/servo/servo/pull/48022)
- window.rs (#47954)
- windowclient.rs (#47954)
- workerglobalscope.rs
- worklet.rs
- writablestream.rs (#47909)
- writablestreamdefaultcontroller.rs (#47909)
- writablestreamdefaultwriter.rs (#47909)
- xrsession.rs (https://github.com/servo/servo/pull/48022)
- xrsystem.rs (https://github.com/servo/servo/pull/48022)
- xrtest.rs (https://github.com/servo/servo/pull/48022)
Source: servo/servo