Novage / p2p-media-loader

An open-source engine for P2P streaming of live and on demand video directly in a web browser HTML page
https://novage.com.ua/p2p-media-loader/demo.html
Apache License 2.0
1.44k stars 315 forks source link

safari websocket #414

Open dsyscms opened 1 month ago

dsyscms commented 1 month ago

When have multiple trackers,Only the first tracker will be loaded,The rest will not load. mac safari and ios safari has this problem.

mac safari version: 17.6

source code: ` this.client = new TrackerClient({ infoHash: utf8ToUintArray(streamHash), peerId: utf8ToUintArray(peerId), announce: isSafariOrWkWebview() ? config.announceTrackers.slice(0, 1) // Safari has issues with multiple trackers : config.announceTrackers, rtcConfig: this.config.rtcConfig, });

`

modify source code:

`

this.client = new TrackerClient({ infoHash: utf8ToUintArray(streamHash), peerId: utf8ToUintArray(peerId), announce: isSafariOrWkWebview() ? config.announceTracker : config.announceTrackers, rtcConfig: this.config.rtcConfig, });

` After testing, it can be used normally even with multiple trackers. I want to know why it cannot be used normally.

mrlika commented 1 month ago

Unfortunately, there is a bug in Safari: it closes WebSocket connections with large messages.

https://bugs.webkit.org/show_bug.cgi?id=228296

Fortunately, there is no this bug if only one WebSocket connection is open.

mrlika commented 1 month ago

You can find the issue:

It is how it looks for us: telegram-cloud-photo-size-2-5451618477648503202-y

We can't reproduce the issue in the latest Safari 18 but are still testing it.

stevenking888 commented 1 month ago

I found that Safari will close web socket connection as default. (Ref: https://www.reddit.com/r/MacOS/comments/qna5js/safari_issue_in_monterey/)

I Google and found that 'disable websocket compression to fix macos monterey safari' but I'm not sure how can I do. I use wt-tracker as tracker

(ref: https://github.com/tilt-dev/tilt/pull/5082)