player icon indicating copy to clipboard operation
player copied to clipboard

`localStorage` not always available, causing TypeErrors

Open ghost opened this issue 1 year ago • 1 comments

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

ghost avatar Sep 27 '24 18:09 ghost

I've also got the same problem for a Nuxt.js project.

randomman552 avatar Sep 03 '25 08:09 randomman552