Skip to content

Commit 3cbf57e

Browse files
authored
fix(ads-client): change MozAdsTelemetry from with_foreign to callback_interface (#7443)
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.
1 parent 8490290 commit 3cbf57e

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

components/ads-client/src/ffi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ impl MozAdsClientBuilder {
162162
self
163163
}
164164

165-
pub fn telemetry(self: Arc<Self>, telemetry: Arc<dyn MozAdsTelemetry>) -> Arc<Self> {
166-
self.0.lock().telemetry = Some(telemetry);
165+
pub fn telemetry(self: Arc<Self>, telemetry: Box<dyn MozAdsTelemetry>) -> Arc<Self> {
166+
self.0.lock().telemetry = Some(Arc::from(telemetry));
167167
self
168168
}
169169
}

components/ads-client/src/ffi/telemetry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::http_cache::{CacheOutcome, HttpCacheBuilderError};
1212
use crate::mars::error::{RecordClickError, RecordImpressionError, ReportAdError};
1313
use crate::telemetry::Telemetry;
1414

15-
#[uniffi::export(with_foreign)]
15+
#[uniffi::export(callback_interface)]
1616
pub trait MozAdsTelemetry: Send + Sync {
1717
fn record_build_cache_error(&self, label: String, value: String);
1818
fn record_client_error(&self, label: String, value: String);

0 commit comments

Comments
 (0)