Skip to content

[Bug]: iOS Safari WebKit frequently runs out of memory and force-reloads the page when using Video.js #425

Open
TypeType-Video/TypeType-Frontend
#135

Description

@Aquarius-Situla

What happened?

When watching videos on iOS Safari with the new Video.js player enabled, WebKit memory frequently spikes/exhausts and iOS terminates the tab process, causing Safari to force-reload the page repeatedly during playback or after switching between a few videos.

I don't have a macOS environment to profile the iOS WebKit memory timeline via Safari Web Inspector locally, so I checked the dev branch frontend code and spotted a few possible causes that I wanted to share in case you can take a look.

Steps to reproduce

  1. Switch to or enable the Video.js player engine on iOS Safari (iPhone).
  2. Play a video (HLS / DASH / SABR) for several minutes, or switch between multiple videos continuously.
  3. Observe Safari suddenly crashing/reloading the page ("A problem repeatedly occurred" / WebKit Jetsam memory limit).

Area

Frontend (web app)

Channel

beta

Anything else?

Possible Causes Spotted in dev

  1. Unbounded HLS buffer in apps/web/src/components/videojs-media.tsx:

    • <HlsJsVideo> currently only passes engine: { hlsJs: { startPosition: live ? -1 : startRef.current / 1000 } } inside hlsSource.
    • It does not appear to wire up the buffer limits from hls-buffer-config.ts (backBufferLength, maxBufferLength, maxMaxBufferLength, maxBufferSize). Under iOS Safari (ManagedMediaSource / MSE), unbounded hls.js backward buffers can quickly hit WebKit's strict per-tab memory cap.
  2. Inline source object & missing buffer pruning on <DashVideo> (apps/web/src/components/videojs-media.tsx):

    • <DashVideo ref={mediaRef} {...mediaProps} source={{ src: source.src }}> creates a new source object literal on every re-render, and doesn't pass dashjs buffer pruning settings (bufferToKeep, bufferPruningInterval, bufferTimeAtTopQuality, etc.), which may cause unnecessary reloads or SourceBuffer retention.
  3. Default preload: "auto", teardown, and GPU layer overhead (apps/web/src/components/videojs-video-player.tsx):

    • mediaProps sets preload: "auto" unconditionally.
    • Ensuring explicit engine destruction plus video.pause(); video.removeAttribute("src"); video.load() on unmount/source switch helps iOS Safari release hardware decoder frames and MediaSource buffers faster.
    • Additionally, @videojs/react/video/skin.css uses backdrop-filter overlays on top of the hardware-decoded video layer, which allocates extra high-resolution IOSurface GPU memory in iOS WebKit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions