bilibili/flv.js · critical · RuntimeException

Your browser doesn't support xhr with arraybuffer responseTy

Error message

Your browser doesn't support xhr with arraybuffer responseType!

What it means

IOController._selectLoader picks the best supported streaming loader: it tries MSE-enhanced fetch, then moz-chunked XHR, then RangeLoader. If none of FetchStreamLoader.isSupported(), MozChunkedLoader.isSupported(), or RangeLoader.isSupported() returns true, it concludes the browser lacks XHR arraybuffer responseType support and throws this RuntimeException.

Source

Thrown at src/io/io-controller.js:251

            this._seekHandler = new config.customSeekHandler();
        } else {
            throw new InvalidArgumentException(`Invalid seekType in config: ${config.seekType}`);
        }
    }

    _selectLoader() {
        if (this._config.customLoader != null) {
            this._loaderClass = this._config.customLoader;
        } else if (this._isWebSocketURL) {
            this._loaderClass = WebSocketLoader;
        } else if (FetchStreamLoader.isSupported()) {
            this._loaderClass = FetchStreamLoader;
        } else if (MozChunkedLoader.isSupported()) {
            this._loaderClass = MozChunkedLoader;
        } else if (RangeLoader.isSupported()) {
            this._loaderClass = RangeLoader;
        } else {
            throw new RuntimeException('Your browser doesn\'t support xhr with arraybuffer responseType!');
        }
    }

    _createLoader() {
        this._loader = new this._loaderClass(this._seekHandler, this._config);
        if (this._loader.needStashBuffer === false) {
            this._enableStash = false;
        }
        this._loader.onContentLengthKnown = this._onContentLengthKnown.bind(this);
        this._loader.onURLRedirect = this._onURLRedirect.bind(this);
        this._loader.onDataArrival = this._onLoaderChunkArrival.bind(this);
        this._loader.onComplete = this._onLoaderComplete.bind(this);
        this._loader.onError = this._onLoaderError.bind(this);
    }

    open(optionalFrom) {
        this._currentRange = {from: 0, to: -1};
        if (optionalFrom) {

View on GitHub (pinned to 42343088f2)

Solutions

  1. Use a browser with XHR arraybuffer or fetch stream support (evergreen Chrome/Firefox/Safari/Edge)
  2. Check that no polyfill/shim is clobbering window.XMLHttpRequest or window.fetch before constructing the player
  3. In Node-based tests, provide a proper XHR mock that supports responseType 'arraybuffer' and isSupported() detection
  4. Bundle a fallback playback path (e.g. plain <video src> progressive playback) for unsupported browsers

Example fix

// before
new IOController(fetchLoader, config, extraData); // throws in legacy webview
// after
if (RangeLoader.isSupported() || FetchStreamLoader.isSupported() || MozChunkedLoader.isSupported()) {
  new IOController(fetchLoader, config, extraData);
} else {
  videoElement.src = progressiveFallbackUrl; // <video> progressive fallback
}
Defensive patterns

Strategy: fallback

Validate before calling

const supportsPlayback =
  (typeof fetch !== 'undefined' && typeof ReadableStream !== 'undefined') ||
  (typeof XMLHttpRequest !== 'undefined' &&
    (new XMLHttpRequest().responseType === '' || 'arraybuffer' in new XMLHttpRequest()));
if (!supportsPlayback) console.warn('no streaming loader supported; use progressive fallback');

Type guard

const canStream = () =>
  typeof window !== 'undefined' &&
  typeof window.XMLHttpRequest === 'function' &&
  (RangeLoader.isSupported() || FetchStreamLoader.isSupported() || MozChunkedLoader.isSupported());

Try / catch

try {
  const controller = new IOController(loaderClass, config, extraData);
} catch (e) {
  if (e instanceof RuntimeException && /arraybuffer responseType/.test(e.message)) {
    enableProgressiveVideoFallback();
  }
}

Prevention

When it happens

Trigger: Calling createLoader/constructor in an environment where fetch ReadableStream is unavailable, XHR overrideMimeType of 'text/plain; charset=x-user-defined' (moz-chunked) is unavailable, and XHR responseType 'arraybuffer' is unsupported — effectively legacy browsers or exotic embedded webviews.

Common situations: Old IE (<=9), some Android WebViews/Smart-TV browsers, sandboxed environments stubbing XMLHttpRequest, unit tests running in Node with an incomplete DOM shim, or environments where feature detection is fooled by polyfills.

Related errors


AI-assisted analysis of bilibili/flv.js@42343088f2 (2026-09-01). Data as JSON: /api/errors/df3610118e8f7238. Report an issue: GitHub.