From 76ffc2d2688845b2fdec02de29b306c56977db6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Torr=C3=B3?= Date: Tue, 1 Apr 2025 09:01:49 +0200 Subject: [PATCH] :wrench: Log error on process animation frame (#6182) --- render-wasm/src/main.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/render-wasm/src/main.rs b/render-wasm/src/main.rs index e0ef988590..82b4f1f2e1 100644 --- a/render-wasm/src/main.rs +++ b/render-wasm/src/main.rs @@ -95,11 +95,24 @@ pub extern "C" fn render(timestamp: i32) { #[no_mangle] pub extern "C" fn process_animation_frame(timestamp: i32) { - with_state!(state, { - state - .process_animation_frame(timestamp) - .expect("Error processing animation frame"); + let result = std::panic::catch_unwind(|| { + with_state!(state, { + state + .process_animation_frame(timestamp) + .expect("Error processing animation frame"); + }); }); + + match result { + Ok(_) => {} + Err(err) => { + match err.downcast_ref::() { + Some(message) => println!("process_animation_frame error: {}", message), + None => println!("process_animation_frame error: {:?}", err), + } + std::panic::resume_unwind(err); + } + } } #[no_mangle]