Description
Web Meeting SDK excellently works in our application in iframe.
But when it is opened in Incognito (Private Browsing) mode then browsers don’t allow to use localStorage in iframes by default.
That’s why such error is displayed: “DOMException: Failed to read the ‘localStorage’ property from ‘Window’: Access is denied for this document.”
We want to support usage of Incognito (Private Browsing) too.
I can confirm that everything is working good in normal browser mode (without Incognito).
So Zoom Meeting SDK is properly added using all instructions.
But for any case I confirm that we did:
- use HTTPS for both main document and iframe
- we use
allow
attribute ofiframe
with'camera; microphone; display-capture; screen-wake-lock; cross-origin-isolated'
values
I searched answers in Developer Support and Developer forum.
I found this: https://devsupport.zoom.us/hc/en-us/articles/10286066139405-Best-practices-when-using-the-Video-SDK-in-an-iFrame
I don’t see anything there that we don’t use yet. As mentioned above - HTTPS and allow
are used
Also I found this: Zoom Web Client - iframe integration
Unfortunately, there is no solution. There are Zoom team asks developer if allow
attribute is used for iframe (as I confirmed above - in our case it is used). Also they ask about whether 3rd party cookies are enabled in browser - no, they are disabled by default in Incognito mode in iframes.
Could you please update Meeting SDK Web to take into account cases when localStorage is not accessible? For example, you could use some local variable instead of local storage as fallback variant.
We see that in some cases your SDK already takes this into account:
try{this.isLocalAvaliable=!0,localStorage.setItem("privateTest","")}catch(t){this.isLocalAvaliable=!1}
in @zoomus/websdk/dist/zoom-meeting-2.9.7.min.js
.
It uses safe try/catch to check whether localStorage is available. So it is not a problem.
But in some cases there is no safe check, and so exception happens that completely breaks Zoom SDK functionality:
42222:function(t,n,e){"use strict";var r=e(63907),o=e(50542),i=e(12478),a="localStorage"in e.g&&e.g.localStorage?e.g.localStorage:r;
in @zoomus/websdk/dist/zoom-meeting-2.9.7.min.js
Here it is not safe, because tries to access localStorage
without try/catch. And so exceptions appears here in iframes in incognito.
Below is suggestion of a solution that you could use in all places of your code, to make sure it is always safe and uses fallback mechanism:
let localStorage = null;
let sessionStorage = null;
(() => {
// Local Storage
try {
window.localStorage.getItem('test-localStorage');
localStorage = window.localStorage;
} catch {
// local storage is not accessible - fallback variant
localStorage = factoryStorage();
}
// Session Storage
try {
window.sessionStorage.getItem('test-localStorage');
sessionStorage = window.sessionStorage;
} catch {
// local storage is not accessible - fallback variant
sessionStorage = factoryStorage();
}
})();
function factoryStorage() {
console.log('ll,replaced');
const memory = new Map();
return {
getItem: (key) => memory.get(key),
setItem: (key, value) => memory.set(key, value),
removeItem: (key) => memory.delete(key),
clear: () => memory.clear(),
get length() {
return memory.size;
}
}
}
export function getLocalStorage() {
return localStorage;
}
export function getSessionStorage() {
return sessionStorage;
}
// usage example
function someFunction() {
// replace:
// const value = window.localStorage.getItem('key');
// by:
const value = getLocalStorage().getItem('key');
}
Browser Console Error
“DOMException: Failed to read the ‘localStorage’ property from ‘Window’: Access is denied for this document.”
Which Web Meeting SDK version?
2.9.7
Meeting SDK Code Snippets
HTML:
<iframe allow="camera; microphone; display-capture; screen-wake-lock; cross-origin-isolated" src="https://---link-to-sample-ZoomMeetingSDKintegratoin" allowfullscreen="true"></iframe>
Open it in Incognito in Google Chrome. And you will see this exception in console.
To Reproduce(If applicable)
- Open Google Chrome in Incognito
- Open page that has iframe with Zoom Meeting SDK Web integration
- Check developer tools console
Device (please complete the following information):
- Device: Macbook Pro
- OS: macOS 13.1
- Browser: Chrome
- Browser Version 110.0.5481.96 (Official Build) (arm64)
Additional context
Incognito mode in Google Chrome with Zoom Meeting SDK Web integration in iframe