Skip to content

Conversation

falcon027
Copy link

Hey everyone,

I couldn’t find a simple way to catch a player panic from host code.
Could Ruffle fire an error event when this happens? Then we could do:

player.addEventListener("error", (err) => console.error("Ruffle panic:", err));

I opened a small PR with a draft implementation, happy to tweak it as needed.

Love the project, thanks for all the hard work!

@Lord-McSweeney Lord-McSweeney added A-web Area: Web & Extensions T-feature Type: New Feature (that Flash doesn't have) waiting-on-review Waiting on review from a Ruffle team member labels Aug 7, 2025
Comment on lines +156 to +161
/**
* Triggered when the ruffle player panict.
*
* @event RufflePlayer#error
*/
static PLAYER_ERROR = "error";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go with

Suggested change
/**
* Triggered when the ruffle player panict.
*
* @event RufflePlayer#error
*/
static PLAYER_ERROR = "error";
/**
* Triggered when the Ruffle player panics.
*
* @event RufflePlayer#panicked
*/
static PANICKED = "panicked";

@@ -2023,7 +2031,9 @@ export class InnerPlayer {
}

errorArray.push(this.getPanicData());


this.element.dispatchEvent(new CustomEvent(InnerPlayer.PLAYER_ERROR, error));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can pass custom data in detail:

Suggested change
this.element.dispatchEvent(new CustomEvent(InnerPlayer.PLAYER_ERROR, error));
this.element.dispatchEvent(new CustomEvent(InnerPlayer.PANICKED, { detail: { error } }));

@kjarosh
Copy link
Member

kjarosh commented Aug 17, 2025

Thanks for the PR BTW, this feature seems reasonable for me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-web Area: Web & Extensions T-feature Type: New Feature (that Flash doesn't have) waiting-on-review Waiting on review from a Ruffle team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants