Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pixel_bridge/build_defs.bzl
Original file line number Diff line number Diff line change
@@ -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",
)
11 changes: 9 additions & 2 deletions pixel_bridge/rust/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,17 +286,24 @@ impl Frames {
}

fn format_panic(err: Box<dyn std::any::Any + Send>) -> 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::<String>() {
msg.as_str()
} 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, T>(f: F) -> Result<T, String>
Expand Down
Loading