Skip to content

Commit ba677e0

Browse files
committed
web: Don't allow repeated reloads with the canvas renderer
1 parent 89dc0b1 commit ba677e0

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

web/packages/core/src/internal/player/inner.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -798,11 +798,14 @@ export class InnerPlayer {
798798
* Reloads the player, as if you called {@link RufflePlayer.load} with the same config as the last time it was called, but setting the preferredRenderer to "canvas".
799799
*
800800
* If this player has never been loaded, this method will return an error.
801+
* If this player was already trying to use the canvas render, this method will panic.
801802
*/
802-
async reloadWithCanvasRenderer(): Promise<void> {
803-
if (this.loadedConfig) {
803+
protected async reloadWithCanvasRenderer(): Promise<void> {
804+
if (this.loadedConfig && this.loadedConfig.preferredRenderer !== RenderBackend.Canvas) {
804805
const combinedOptions = { ...this.loadedConfig, preferredRenderer: RenderBackend.Canvas};
805806
await this.load(combinedOptions);
807+
} else if (this.loadedConfig) {
808+
this.panic(new Error(text("error-canvas-reload")));
806809
} else {
807810
throw new Error("Cannot reload if load wasn't first called");
808811
}

web/packages/core/texts/en-US/messages.ftl

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ clipboard-message-description =
2424
clipboard-message-copy = { " " } for copy
2525
clipboard-message-cut = { " " } for cut
2626
clipboard-message-paste = { " " } for paste
27+
error-canvas-reload = Cannot reload with the canvas renderer when the canvas renderer is already in use.
2728
error-file-protocol =
2829
It appears you are running Ruffle on the "file:" protocol.
2930
This doesn't work as browsers block many features from working for security reasons.

0 commit comments

Comments
 (0)