OpenVidu / openvidu

OpenVidu Platform main repository
https://openvidu.io
Apache License 2.0
1.86k stars 464 forks source link

Tolerate inaccessible localStorage #816

Closed semmel closed 12 months ago

semmel commented 1 year ago

Fixes the issue

With cross-site (aka third-party) cookies are blocked , media streams will fail to play in a cross-origin iframe. E.g. Chrome's Incognito mode, or Chrome and Firefox with Settings-> Privacy & Security -> Cookies and other site data -> Block third-party-cookies.

Reason

WebRtcStats::initWebRtcStats() throws a DOMException

When cross-site (aka third-party) cookies are blocked by the browser, accessing localStorage in a third-party iframe throws a DOMException.

Fix

When reading from localStorage treat (security) exceptions like absent values. Apart from reading from localStorage in WebRtcStats::initWebRtcStats(), openvidu-browser does not access localStorage or sessionStorage anywhere else.

pabloFuente commented 12 months ago

Thank you for your PR. It is a simple change that looks good. It is now approved and part of the master branch.

semmel commented 12 months ago

@pabloFuente Great! Thank you!