From 38d1237f8966a0aac7857872ed5b5bda356cfb31 Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 8 Jul 2026 08:55:28 -0700 Subject: [PATCH] Hide ImageFormat From traits to avoid LLVM PC32 relocation limits PiperOrigin-RevId: 944527188 --- pixel_bridge/build_defs.bzl | 18 ++++++++++++++++++ pixel_bridge/rust/image.rs | 11 +++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 pixel_bridge/build_defs.bzl diff --git a/pixel_bridge/build_defs.bzl b/pixel_bridge/build_defs.bzl new file mode 100644 index 0000000..14fd0b6 --- /dev/null +++ b/pixel_bridge/build_defs.bzl @@ -0,0 +1,18 @@ +"""Build definitions for pixel bridge.""" + +# Platforms where Rust decoding is unavailable. +UNSUPPORTED_PLATFORMS_RUST = ( + "//tools/cc_target_os:chromiumos", + "//tools/cc_target_os:darwin", + "//tools/cc_target_os:fuchsia", + "//tools/cc_target_os:android", + "//tools/cc_target_os:wasm", + "//tools/cc_target_os:hercules_embedded", + "//tools/cc_target_os:platform_ios", + "//tools/cc_target_os:platform_tvos", + "//tools/cc_target_os:platform_visionos", + "//tools/cc_target_os:platform_watchos", + "//tools/cc_target_os:mpu64", + "//tools/cc_target_os:nestcam_ambarella", + "//tools/cc_target_os:windows", +) diff --git a/pixel_bridge/rust/image.rs b/pixel_bridge/rust/image.rs index 413a8a6..9b8b731 100644 --- a/pixel_bridge/rust/image.rs +++ b/pixel_bridge/rust/image.rs @@ -286,7 +286,6 @@ impl Frames { } fn format_panic(err: Box) -> String { - let backtrace = std::backtrace::Backtrace::capture(); let msg = if let Some(msg) = err.downcast_ref::<&str>() { *msg } else if let Some(msg) = err.downcast_ref::() { @@ -294,9 +293,17 @@ fn format_panic(err: Box) -> String { } else { "Unknown panic payload" }; + + // Capturing backtraces under TSAN can cause deadlocks. + let backtrace = if std::env::var("RUST_BACKTRACE").is_ok() { + format!("\nBacktrace:\n{}", std::backtrace::Backtrace::capture()) + } else { + String::new() + }; + // This error message needs to start with "Rust panic caught", as // that is how we identify it on the C++ side. - format!("Rust panic caught: {}\nBacktrace:\n{}", msg, backtrace) + format!("Rust panic caught: {}{}", msg, backtrace) } fn run_catching_panics(f: F) -> Result