Skip to content

Commit b67326f

Browse files
committed
fix(ads-client): change MozAdsTelemetry from with_foreign to callback_interface
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 242220a commit b67326f

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
@@ -157,8 +157,8 @@ impl MozAdsClientBuilder {
157157
self
158158
}
159159

160-
pub fn telemetry(self: Arc<Self>, telemetry: Arc<dyn MozAdsTelemetry>) -> Arc<Self> {
161-
self.0.lock().telemetry = Some(telemetry);
160+
pub fn telemetry(self: Arc<Self>, telemetry: Box<dyn MozAdsTelemetry>) -> Arc<Self> {
161+
self.0.lock().telemetry = Some(Arc::from(telemetry));
162162
self
163163
}
164164
}

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)