ruffle-rs / ruffle

A Flash Player emulator written in Rust
https://ruffle.rs
Other
15.63k stars 809 forks source link

WebSockets send and receive nothing when tab is not focused #13617

Open robinheidrich opened 1 year ago

robinheidrich commented 1 year ago

Describe the bug

If the tab on which Ruffle is running is not focused, no packets will be sent or received by WebSockets.

Expected behavior

Even when the tab is not focused, WebSockets should still be sending and receiving packets.

An example is multiplayer games that need to continue in the background or send pings.

Affected platform

Self-hosted version

Operating system

Windows 11

Browser

Google Chrome 118

Additional information

No response

sleepycatcoding commented 1 year ago

This is expected behavior, since Ruffle uses browser's requestAnimationFrame callback to tick the player. These calls are paused by most browsers when the tab is in the background to improve performance and battery life.

robinheidrich commented 1 year ago

This is expected behavior, since Ruffle uses browser's requestAnimationFrame callback to tick the player. These calls are paused by most browsers when the tab is in the background to improve performance and battery life.

That's what I thought. Couldn't Ruffle use a web worker or something for this, so that no packets get lost? Or is that not planned?