player
player copied to clipboard
`localStorage` not always available, causing TypeErrors
Current Behavior:
When a user loads a site with vidstack in an Android Mobile WebView, localStorage is not always available (depending on the WebView). Therefore the following error is raised:
TypeError: Cannot read properties of null (reading 'getItem')
Expected Behavior:
No error/exception is raised, localStorage is null-checked and ignored if null.
Steps To Reproduce:
Use an Android application that opens an embedded webview when opening a link. Share a link to a page with vidstack.
Reproduction Link: https://www.vidstack.io/player/demo?framework=react&view=player
Easiest way to reproduce:
- In Firefox, go to about:config, disable
dom.storage.enable. - Navigate to the demo page, it will crash.
Environment:
- Framework: React
- Meta Framework: Next.js
- Node: 20.11.0
- OS: Android 11
- Browser: Chrome Mobile WebView 128.0.6613
I've also got the same problem for a Nuxt.js project.