Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The newest shaka.net.HttpFetchPlugin is incompatible with Fetch API provided by Chrome/Edge/Firefox on iOS #5088

Closed
NoChance777 opened this issue Mar 13, 2023 · 7 comments · Fixed by #5091
Assignees
Labels
platform: iOS Issues affecting iOS priority: P0 Broken for everyone; no workaround; urgent status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Milestone

Comments

@NoChance777
Copy link
Contributor

NoChance777 commented Mar 13, 2023

Have you read the FAQ and checked for duplicate open issues?
Yes

What version of Shaka Player are you using?
4.3.4

Can you reproduce the issue with our latest release version?
Yes

Can you reproduce the issue with the latest code from main?
Yes

Are you using the demo app or your own custom app?
Our custom app

If custom app, can you reproduce the issue using our demo app?
Yes

What browser and OS are you using?
Edge 110.0.1587.63 Chrome 110.0.5481.114 Firefox 110.1 (28420) on iOS 16.3.1

For embedded devices (smart TVs, etc.), what model and firmware version are you using?

What are the manifest and license server URIs?

What configuration are you using? What is the output of player.getConfiguration()?

{
  "drm": {
    "retryParameters": {
      "maxAttempts": 2,
      "baseDelay": 1000,
      "backoffFactor": 2,
      "fuzzFactor": 0.5,
      "timeout": 30000,
      "stallTimeout": 5000,
      "connectionTimeout": 10000
    },
    "servers": {
      "com.apple.fps.1_0": "https://licenses.drm.xxx.net/drm/v1/ksm?token=xxx"
    },
    "clearKeys": {},
    "advanced": {
      "com.apple.fps.1_0": {
        "distinctiveIdentifierRequired": false,
        "persistentStateRequired": false,
        "videoRobustness": "",
        "audioRobustness": "",
        "sessionType": "",
        "serverCertificate": {},
        "serverCertificateUri": "https://ac-009.live.xxx.net/drm/fps/xxx",
        "individualizationServer": ""
      }
    },
    "delayLicenseRequestUntilPlayed": false,
    "logLicenseExchange": true,
    "updateExpirationTime": 1,
    "preferredKeySystems": [],
    "keySystemsMapping": {},
    "parseInbandPsshEnabled": false,
    "minHdcpVersion": ""
  },
  "manifest": {
    "retryParameters": {
      "maxAttempts": 1,
      "baseDelay": 1000,
      "backoffFactor": 2,
      "fuzzFactor": 0.5,
      "timeout": 30000,
      "stallTimeout": 5000,
      "connectionTimeout": 10000
    },
    "availabilityWindowOverride": null,
    "disableAudio": false,
    "disableVideo": false,
    "disableText": false,
    "disableThumbnails": false,
    "defaultPresentationDelay": 0,
    "segmentRelativeVttTiming": true,
    "dash": {
      "clockSyncUri": "",
      "ignoreDrmInfo": false,
      "disableXlinkProcessing": false,
      "xlinkFailGracefully": false,
      "ignoreMinBufferTime": true,
      "autoCorrectDrift": true,
      "initialSegmentLimit": 1000,
      "ignoreSuggestedPresentationDelay": false,
      "ignoreEmptyAdaptationSet": false,
      "ignoreMaxSegmentDuration": false,
      "keySystemsByURI": {
        "urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b": "org.w3.clearkey",
        "urn:uuid:e2719d58-a985-b3c9-781a-b030af78d30e": "org.w3.clearkey",
        "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed": "com.widevine.alpha",
        "urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95": "com.microsoft.playready",
        "urn:uuid:79f0049a-4098-8642-ab92-e65be0885f95": "com.microsoft.playready",
        "urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb": "com.adobe.primetime"
      },
      "sequenceMode": false
    },
    "hls": {
      "ignoreTextStreamFailures": false,
      "ignoreImageStreamFailures": false,
      "defaultAudioCodec": "mp4a.40.2",
      "defaultVideoCodec": "avc1.42E01E",
      "ignoreManifestProgramDateTime": false,
      "mediaPlaylistFullMimeType": "video/mp2t; codecs=\\"avc1.42E01E, mp4a.40.2\\"",
      "useSafariBehaviorForLive": true,
      "liveSegmentsDelay": 3,
      "sequenceMode": true
    }
  },
  "streaming": {
    "retryParameters": {
      "maxAttempts": 20,
      "baseDelay": 1000,
      "backoffFactor": 2,
      "fuzzFactor": 0.5,
      "timeout": 30000,
      "stallTimeout": 5000,
      "connectionTimeout": 10000
    },
    "rebufferingGoal": 2,
    "bufferingGoal": 10,
    "bufferBehind": 30,
    "ignoreTextStreamFailures": false,
    "alwaysStreamText": false,
    "startAtSegmentBoundary": false,
    "gapDetectionThreshold": 0.5,
    "durationBackoff": 1,
    "safeSeekOffset": 5,
    "stallEnabled": true,
    "stallThreshold": 1,
    "stallSkip": 0.1,
    "useNativeHlsOnSafari": true,
    "inaccurateManifestTolerance": 2,
    "lowLatencyMode": false,
    "autoLowLatencyMode": false,
    "forceHTTPS": false,
    "preferNativeHls": true,
    "updateIntervalSeconds": 1,
    "dispatchAllEmsgBoxes": false,
    "observeQualityChanges": false,
    "maxDisabledTime": 30,
    "parsePrftBox": false,
    "segmentPrefetchLimit": 0
  },
  "mediaSource": {
    "sourceBufferExtraFeatures": "",
    "forceTransmux": false
  },
  "offline": {
    "usePersistentLicense": true,
    "numberOfParallelDownloads": 5
  },
  "abr": {
    "enabled": true,
    "useNetworkInformation": true,
    "defaultBandwidthEstimate": 1000000,
    "switchInterval": 8,
    "bandwidthUpgradeTarget": 0.85,
    "bandwidthDowngradeTarget": 0.95,
    "restrictions": {
      "minWidth": 0,
      "maxWidth": null,
      "minHeight": 0,
      "maxHeight": null,
      "minPixels": 0,
      "maxPixels": null,
      "minFrameRate": 0,
      "maxFrameRate": null,
      "minBandwidth": 0,
      "maxBandwidth": null
    },
    "advanced": {
      "minTotalBytes": 128000,
      "minBytes": 16000,
      "fastHalfLife": 2,
      "slowHalfLife": 5
    },
    "restrictToElementSize": false,
    "restrictToScreenSize": false,
    "ignoreDevicePixelRatio": false
  },
  "autoShowText": 3,
  "preferredAudioLanguage": "",
  "preferredAudioLabel": "",
  "preferredTextLanguage": "",
  "preferredVariantRole": "",
  "preferredTextRole": "",
  "preferredAudioChannelCount": 2,
  "preferredVideoCodecs": [],
  "preferredAudioCodecs": [],
  "preferForcedSubs": false,
  "preferredDecodingAttributes": [],
  "restrictions": {
    "minWidth": 0,
    "maxWidth": null,
    "minHeight": 0,
    "maxHeight": null,
    "minPixels": 0,
    "maxPixels": null,
    "minFrameRate": 0,
    "maxFrameRate": null,
    "minBandwidth": 0,
    "maxBandwidth": null
  },
  "playRangeStart": 0,
  "playRangeEnd": null,
  "cmcd": {
    "enabled": false,
    "sessionId": "",
    "contentId": "",
    "useHeaders": false
  },
  "lcevc": {
    "enabled": false,
    "dynamicPerformanceScaling": true,
    "logLevel": 0,
    "drawLogo": false
  }
}

What did you do?
Try to play any DRM protected content in Chrome/Edge/Firefox on iOS 16.

What did you expect to happen?
shaka-player does successful request to any DRM server and can parse a response.

What actually happened?
You will get an error during request to DRM server if you try to use shaka-player in specified browsers on iOS
The exception comes from http_fetch_plugin.js file at line 129:

const reader = response.clone().body.getReader();

It seems like all these browsers are built on outdated version of the WebKit which doesn't support modern Fetch API. The error's message is

TypeError: undefined is not an object (evaluating 'l.clone().body.getReader'),2)

You can also reproduce this bug on a desktop platform if you use this polyfill https://github.com/github/fetch
falling back to http_xhr_plugin.js solves the issue

@NoChance777 NoChance777 added the type: bug Something isn't working correctly label Mar 13, 2023
@avelad avelad added priority: P0 Broken for everyone; no workaround; urgent platform: iOS Issues affecting iOS labels Mar 13, 2023
@avelad avelad added this to the v4.4 milestone Mar 13, 2023
@avelad
Copy link
Member

avelad commented Mar 13, 2023

@joeyparrish It seems that response.clone().body is undefined and getReader is not supported

@avelad
Copy link
Member

avelad commented Mar 13, 2023

A basic solution is to detect response.body, and avoid using ReadableStream if it's not supported response.body...

If we do this we lose support for DASH-LL, but at least something would work.

@joeyparrish what do you think?

@avelad
Copy link
Member

avelad commented Mar 13, 2023

Well... reading the implementation... this causes progress events to be lost. So It is best not to use fetch in these cases.

@joeyparrish Is there a way to ban fetch if it doesn't support body in the response? Similar to https://github.com/shaka-project/shaka-player/blob/main/lib/net/http_fetch_plugin.js#L233

@friday
Copy link
Contributor

friday commented Mar 13, 2023

Add new Response('').clone().body to the condition?

Or if clone isn't the problem maybe just new Response('').body or Response.prototype.hasOwnProperty('body')? I can't test this myself. Just some ideas.

@avelad
Copy link
Member

avelad commented Mar 13, 2023

Yes, it works. I think it's better Response.prototype.hasOwnProperty('body')

@avelad
Copy link
Member

avelad commented Mar 13, 2023

I'm working on a PR for it!

@NoChance777
Copy link
Contributor Author

That was lightning fast. Thanks for your work and the great product!

@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label May 13, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform: iOS Issues affecting iOS priority: P0 Broken for everyone; no workaround; urgent status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants