From 9b58b0895a86c809b7211c37bfd80841fb98f57f Mon Sep 17 00:00:00 2001 From: ahanot Date: Mon, 22 Jun 2026 15:24:15 -0400 Subject: [PATCH] fix(ads-client): change MozAdsTelemetry from with_foreign to callback_interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MozAdsTelemetry is always implemented by the foreign side (JS/Kotlin/Swift) and is only ever passed from foreign code to Rust — never the other way around. callback_interface is the correct semantic for this pattern and enables the geckojs uniffi-bindgen-gecko-js pipeline to generate FireAndForget vtable handlers, avoiding a deadlock where Rust calls telemetry methods synchronously from within a callSync on the JS main thread. --- components/ads-client/src/ffi.rs | 4 ++-- components/ads-client/src/ffi/telemetry.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/ads-client/src/ffi.rs b/components/ads-client/src/ffi.rs index a6867514b5..eceaa699f2 100644 --- a/components/ads-client/src/ffi.rs +++ b/components/ads-client/src/ffi.rs @@ -157,8 +157,8 @@ impl MozAdsClientBuilder { self } - pub fn telemetry(self: Arc, telemetry: Arc) -> Arc { - self.0.lock().telemetry = Some(telemetry); + pub fn telemetry(self: Arc, telemetry: Box) -> Arc { + self.0.lock().telemetry = Some(Arc::from(telemetry)); self } } diff --git a/components/ads-client/src/ffi/telemetry.rs b/components/ads-client/src/ffi/telemetry.rs index 55af52db58..70972bf66f 100644 --- a/components/ads-client/src/ffi/telemetry.rs +++ b/components/ads-client/src/ffi/telemetry.rs @@ -12,7 +12,7 @@ use crate::http_cache::{CacheOutcome, HttpCacheBuilderError}; use crate::mars::error::{RecordClickError, RecordImpressionError, ReportAdError}; use crate::telemetry::Telemetry; -#[uniffi::export(with_foreign)] +#[uniffi::export(callback_interface)] pub trait MozAdsTelemetry: Send + Sync { fn record_build_cache_error(&self, label: String, value: String); fn record_client_error(&self, label: String, value: String);