shaka-project / shaka-player

JavaScript player library / DASH & HLS client / MSE-EME player
Apache License 2.0
7.2k stars 1.34k forks source link

Some live content causes BUFFER_READ_OUT_OF_BOUNDS in specific timeframes #5416

Closed cristian-atehortua closed 1 year ago

cristian-atehortua commented 1 year ago

Have you read the FAQ and checked for duplicate open issues? Yes. It looks like is related to #3659 and #5251, however, these issues are closed now and we are still getting the same.

What version of Shaka Player are you using? 4.3.7

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

Can you reproduce the issue with the latest code from main? Not tested, because since it happens in specific timeframes we need to put this in production.

Are you using the demo app or your own custom app? Custom app.

If custom app, can you reproduce the issue using our demo app? Not yet, I will provide the results when I test since it should happen at a specific time.

What browser and OS are you using? It happens in every platform (Web in any OS, any SmartTV)

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

What are the manifest and license server URIs?

I will provide instructions by mail

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

{
  "drm": {
    "retryParameters": {
      "maxAttempts": 3,
      "baseDelay": 1000,
      "backoffFactor": 2,
      "fuzzFactor": 0.5,
      "timeout": 30000,
      "stallTimeout": 12000,
      "connectionTimeout": 17000
    },
    "servers": {},
    "clearKeys": {},
    "advanced": {},
    "delayLicenseRequestUntilPlayed": false,
    "logLicenseExchange": false,
    "updateExpirationTime": 1,
    "preferredKeySystems": [],
    "keySystemsMapping": {},
    "parseInbandPsshEnabled": false
  },
  "manifest": {
    "retryParameters": {
      "maxAttempts": 3,
      "baseDelay": 1000,
      "backoffFactor": 2,
      "fuzzFactor": 0.5,
      "timeout": 30000,
      "stallTimeout": 12000,
      "connectionTimeout": 17000
    },
    "availabilityWindowOverride": null,
    "disableAudio": false,
    "disableVideo": false,
    "disableText": false,
    "disableThumbnails": false,
    "defaultPresentationDelay": 0,
    "segmentRelativeVttTiming": false,
    "dash": {
      "clockSyncUri": "",
      "ignoreDrmInfo": false,
      "disableXlinkProcessing": false,
      "xlinkFailGracefully": false,
      "ignoreMinBufferTime": false,
      "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
    }
  },
  "streaming": {
    "retryParameters": {
      "maxAttempts": 3,
      "baseDelay": 1000,
      "backoffFactor": 2,
      "fuzzFactor": 0.5,
      "timeout": 30000,
      "stallTimeout": 12000,
      "connectionTimeout": 17000
    },
    "rebufferingGoal": 2,
    "bufferingGoal": 30,
    "bufferBehind": 12,
    "ignoreTextStreamFailures": true,
    "alwaysStreamText": false,
    "startAtSegmentBoundary": false,
    "gapDetectionThreshold": 0.5,
    "durationBackoff": 1,
    "forceTransmux": false,
    "safeSeekOffset": 5,
    "stallEnabled": true,
    "stallThreshold": 1,
    "stallSkip": 0.1,
    "useNativeHlsOnSafari": true,
    "inaccurateManifestTolerance": 2,
    "lowLatencyMode": false,
    "autoLowLatencyMode": true,
    "forceHTTPS": false,
    "preferNativeHls": false,
    "updateIntervalSeconds": 1,
    "dispatchAllEmsgBoxes": false,
    "observeQualityChanges": false,
    "maxDisabledTime": 30,
    "parsePrftBox": false
  },
  "mediaSource": {
    "sourceBufferExtraFeatures": ""
  },
  "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": "",
  "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?

  1. Play the provided content
  2. Enable Closed caption
  3. Wait until specific Segment plays ()

What did you expect to happen? Content should continue playback normally

What actually happened?

The 3000 - BUFFER_READ_OUT_OF_BOUNDS is thrown in some segments of this content.

Additional information Something is happening with specific segments of this content. However, on players on other platforms, this error doesn't occur. The player is able to reproduce the segment normally.

This is the stack trace of the error:

index.js:1 Player reported warning Error: Shaka Error MEDIA.BUFFER_READ_OUT_OF_BOUNDS ()
    at new push../node_modules/shaka-player/dist/shaka-player.compiled.debug.js.shaka.util.Error (error.js:94:1)
    at push../node_modules/shaka-player/dist/shaka-player.compiled.debug.js.shaka.util.DataViewReader.outOfBounds_ (data_view_reader.js:267:1)
    at push../node_modules/shaka-player/dist/shaka-player.compiled.debug.js.shaka.util.DataViewReader.readUint16 (data_view_reader.js:100:1)
    at push../node_modules/shaka-player/dist/shaka-player.compiled.debug.js.shaka.cea.CeaDecoder.extract (cea_decoder.js:120:1)
    at push../node_modules/shaka-player/dist/shaka-player.compiled.debug.js.shaka.media.ClosedCaptionParser.parseFrom (closed_caption_parser.js:92:1)
    at push../node_modules/shaka-player/dist/shaka-player.compiled.debug.js.$jscomp.generator.Engine_.program_ (media_source_engine.js:669:1)
    at push../node_modules/shaka-player/dist/shaka-player.compiled.debug.js.$jscomp.generator.Engine_.nextStep_ (generator_engine.js:795:1)
    at push../node_modules/shaka-player/dist/shaka-player.compiled.debug.js.$jscomp.generator.Engine_.next_ (generator_engine.js:699:1)
    at push../node_modules/shaka-player/dist/shaka-player.compiled.debug.js.$jscomp.generator.Generator_.next (generator_engine.js:833:1)
    at execute_async_generator.js:72:1
    at new Promise (<anonymous>)
    at push../node_modules/shaka-player/dist/shaka-player.compiled.debug.js.$jscomp.asyncExecutePromiseGenerator (execute_async_generator.js:59:1)
    at push../node_modules/shaka-player/dist/shaka-player.compiled.debug.js.$jscomp.asyncExecutePromiseGeneratorProgram (execute_async_generator.js:116:1)
    at push../node_modules/shaka-player/dist/shaka-player.compiled.debug.js.shaka.media.MediaSourceEngine.appendBuffer (media_source_engine.js:589:1)
    at push../node_modules/shaka-player/dist/shaka-player.compiled.debug.js.$jscomp.generator.Engine_.program_ (streaming_engine.js:1785:1)
    at push../node_modules/shaka-player/dist/shaka-player.compiled.debug.js.$jscomp.generator.Engine_.nextStep_ (generator_engine.js:795:1)
    at push../node_modules/shaka-player/dist/shaka-player.compiled.debug.js.$jscomp.generator.Engine_.next_ (generator_engine.js:699:1)
    at push../node_modules/shaka-player/dist/shaka-player.compiled.debug.js.$jscomp.generator.Generator_.next (generator_engine.js:833:1)
    at b (execute_async_generator.js:52:1)
avelad commented 1 year ago

I think it's fixed with https://github.com/shaka-project/shaka-player/pull/5422, can you try again against the main branch? Thanks!

github-actions[bot] commented 1 year ago

Closing due to inactivity. If this is still an issue for you or if you have further questions, the OP can ask shaka-bot to reopen it by including @shaka-bot reopen in a comment.

cristian-atehortua commented 1 year ago

@shaka-bot reopen

We are still getting this error in our content with Shaka v4.3.8

image

image

joeyparrish commented 1 year ago

v4.3.8 was released in July, and we have done 3 more releases from v4.3.x since then. The latest is v4.3.11. But there have been no changes to lib/cea/ or other relevant parts of your backtrace since v4.3.8.

Thanks for reopening.

Based on the stack trace and error code, it seems like the packet we're trying to decode ends after the first byte. If the packet is truncated for some reason, one could assume there's no useful info in it and we should ignore it (and maybe log a warning in debug mode) instead of throwing an error.

Are you willing to try a patch for us? I'm wondering if we can get away with changing this line of lib/media/closed_caption_parser.js:

        this.ceaDecoder_.extract(uint8ArrayData, captionPacket.pts);

Into this:

        try {
          this.ceaDecoder_.extract(uint8ArrayData, captionPacket.pts);
        } catch (error) {
          shaka.log.warning('CEA decoding error, ignoring packet!', error);
        }

If this warning coincides with missing captions during playback, we would have to dig more deeply and figure out whether the data we need is actually in the packet or not. If it is, there would be a bug in the parser, and if not, there would be a bug in your encoder. But if this suppression of the out-of-bounds error suffices, it would be a very simple fix.

@cristian-atehortua, what do you think? Could you try it out?

cristian-atehortua commented 1 year ago

Hi @joeyparrish. Thanks for your answer, I mentioned V4.3.8 because that was the one that included #5422.

I will try what you mentioned

Thanks.

avelad commented 1 year ago

@cristian-atehortua do you have any news about the test? Thanks!

shaka-bot commented 1 year ago

Closing due to inactivity. If this is still an issue for you or if you have further questions, the OP can ask shaka-bot to reopen it by including @shaka-bot reopen in a comment.