From 69d1e903fb53409b3f03f92e596145b3bf9e8710 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sat, 12 Sep 2020 21:10:46 +0200 Subject: [PATCH] web: Destroy shouldn't be able to throw exceptions --- web/packages/core/src/ruffle-player.js | 15 ++------------- web/src/lib.rs | 5 ++--- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/web/packages/core/src/ruffle-player.js b/web/packages/core/src/ruffle-player.js index 5785143dd..38b57bd8b 100644 --- a/web/packages/core/src/ruffle-player.js +++ b/web/packages/core/src/ruffle-player.js @@ -126,11 +126,7 @@ exports.RufflePlayer = class RufflePlayer extends HTMLElement { */ async ensure_fresh_instance() { if (this.instance) { - try { - this.instance.destroy(); - } catch (e) { - console.warn("Error destroying old ruffle player:", e); - } + this.instance.destroy(); this.instance = null; console.log("Ruffle instance destroyed."); } @@ -313,14 +309,7 @@ exports.RufflePlayer = class RufflePlayer extends HTMLElement { */ panic() { if (this.instance) { - try { - this.instance.destroy(); - } catch (e) { - console.error( - "Whilst panicking ruffle, an additional error was encountered during destruction:", - e - ); - } + this.instance.destroy(); this.instance = null; } // Clears out any existing content (ie play button or canvas) and replaces it with the error screen diff --git a/web/src/lib.rs b/web/src/lib.rs index dab69b110..4ba0bace6 100644 --- a/web/src/lib.rs +++ b/web/src/lib.rs @@ -152,7 +152,7 @@ impl Ruffle { }); } - pub fn destroy(&mut self) -> Result<(), JsValue> { + pub fn destroy(&mut self) { // Remove instance from the active list. if let Some(instance) = INSTANCES.with(|instances| { let mut instances = instances.borrow_mut(); @@ -175,13 +175,12 @@ impl Ruffle { // Cancel the animation handler, if it's still active. if let Some(id) = instance.animation_handler_id { if let Some(window) = web_sys::window() { - return window.cancel_animation_frame(id.into()); + let _ = window.cancel_animation_frame(id.into()); } } } // Player is dropped at this point. - Ok(()) } #[allow(clippy::boxed_local)] // for js_bind