Safari trotting down WebSocket

Post here your questions about the HTML5 / JavaScript for SFS2X

Moderators: Lapo, Bax

mmilen
Posts: 298
Joined: 09 Nov 2010, 00:48
Contact:

Safari trotting down WebSocket

Postby mmilen » 22 Jul 2020, 04:08

Hi Guy,

We have our latest project up and running in production. It is a React WebPack app and SFS JS API. All is good with Chrome and browser with Chromium. We are running in a problem with Safari on Mac OS, it looks like Safari is starving the JS engine or the WebSocket when Safari window loses focus.

Any ideas?

Milen
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Safari trotting down WebSocket

Postby Lapo » 22 Jul 2020, 08:25

Hi,
can you give us more details about the issue? What happens exactly?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
mmilen
Posts: 298
Joined: 09 Nov 2010, 00:48
Contact:

Re: Safari trotting down WebSocket

Postby mmilen » 22 Jul 2020, 13:29

Load a React-based App in Safari and connect it to latest smart fox server. Enable Ping-Pong on the connection every 10 seconds. If your Safari window is in focus ad the tab with the App is opened you can see on the server admin Ping Pong every 10 seconds. If you go to a new tab in Safari to check on something else, and stay away for longer than 10 seconds, you can see on the smart fox server how the time between ping-pongs start to increase. As soon as the tab of the App is back in focus the ping pong time is back to 10 seconds.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Safari trotting down WebSocket

Postby Lapo » 22 Jul 2020, 15:34

I've tested with a slightly old Safari (under OS X 10.14) and I can see what you're describing. It starts delaying the calls after a few minutes and becomes more and more inconsistent with the timing.
It sounds like Safari does this to save resources at the expenses of the JS/HTML code running in the background.

The fact that the application "slows" down shouldn't be a problem is the User is not using it anyways, no?
Also the Lag Monitor does not reset the Session's idle timer so even if it slows down, it's not going to make a difference as regards to when the User is kicked out due to idleness.

How exactly this "slow down" in Safari affects the functionality of your app?

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
mmilen
Posts: 298
Joined: 09 Nov 2010, 00:48
Contact:

Re: Safari trotting down WebSocket

Postby mmilen » 23 Jul 2020, 04:32

On every Ping-Pong I do send a message to a custom keep-alive extension that in turn sets a user lag variable, so other players can be aware if the user is on more than 300ms lag. and it resets the idle timer. I have my lag monitor set to fire every 10 seconds.

As for how the delay affects the App. It is a teaching App and a teacher sometimes shares screen in Zoom, and shows the students a few things, which are also reflected on the WebApp, but as Safari is not in focus, it does not receive anything, and when it gets in focus the results are undefined. Most of the time it will just roll the messages from server and all is good, but occasionally it's a bit messy with the screen refresh. Life with Apple used to be fun, lately not so much :).

I asked cause I was not sure if it is our implementation. SmartFox is super cool tool to build classrooms for specific educational purposes.
mmilen
Posts: 298
Joined: 09 Nov 2010, 00:48
Contact:

Re: Safari trotting down WebSocket

Postby mmilen » 23 Jul 2020, 04:42

More on how it effects us. In our teaching sessions, there are times when the student just watches, but they can accidentally click away from Safari, and effectively they can't see what the teacher is doing :).
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Safari trotting down WebSocket

Postby Lapo » 23 Jul 2020, 06:47

Maybe you could recommend to use a different browser, such as Chrome.
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X HTML5 / JavaScript API”

Who is online

Users browsing this forum: No registered users and 16 guests