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

Buffering event fired too late #6527

Closed
alexandercerutti opened this issue May 2, 2024 · 4 comments · Fixed by #6546
Closed

Buffering event fired too late #6527

alexandercerutti opened this issue May 2, 2024 · 4 comments · Fixed by #6546
Labels
priority: P1 Big impact or workaround impractical; resolve before feature release type: bug Something isn't working correctly
Milestone

Comments

@alexandercerutti
Copy link
Contributor

alexandercerutti commented May 2, 2024

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

If the problem is related to FairPlay, have you read the tutorial?

What version of Shaka Player are you using?

4.8.1

Can you reproduce the issue with our latest release version?

Yes

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

Not tested

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?

What browser and OS are you using?

Chrome on MacOS 13.6.2 - testing a CTV application on browser

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()?

Open config
{
    "drm": {
  	  "retryParameters": {
  		  "maxAttempts": 2,
  		  "baseDelay": 1000,
  		  "backoffFactor": 2,
  		  "fuzzFactor": 0.5,
  		  "timeout": 30000,
  		  "stallTimeout": 5000,
  		  "connectionTimeout": 10000
  	  },
  	  "servers": {
  		  "com.widevine.alpha": <redacted>,
  		  "com.microsoft.playready": <redacted>
  	  },
  	  "clearKeys": {},
  	  "advanced": {
  		  "com.microsoft.playready": {
  			  "distinctiveIdentifierRequired": false,
  			  "persistentStateRequired": false,
  			  "videoRobustness": "",
  			  "audioRobustness": "",
  			  "sessionType": "",
  			  "serverCertificate": {},
  			  "serverCertificateUri": "",
  			  "individualizationServer": ""
  		  }
  	  },
  	  "delayLicenseRequestUntilPlayed": false,
  	  "persistentSessionOnlinePlayback": false,
  	  "persistentSessionsMetadata": [],
  	  "logLicenseExchange": false,
  	  "updateExpirationTime": 1,
  	  "preferredKeySystems": [],
  	  "keySystemsMapping": {},
  	  "parseInbandPsshEnabled": false,
  	  "minHdcpVersion": "",
  	  "ignoreDuplicateInitData": true
    },
    "manifest": {
  	  "retryParameters": {
  		  "maxAttempts": 2,
  		  "baseDelay": 1000,
  		  "backoffFactor": 2,
  		  "fuzzFactor": 0.5,
  		  "timeout": 30000,
  		  "stallTimeout": 5000,
  		  "connectionTimeout": 10000
  	  },
  	  "availabilityWindowOverride": null,
  	  "disableAudio": false,
  	  "disableVideo": false,
  	  "disableText": false,
  	  "disableThumbnails": false,
  	  "defaultPresentationDelay": 10,
  	  "segmentRelativeVttTiming": false,
  	  "raiseFatalErrorOnManifestUpdateRequestFailure": false,
  	  "dash": {
  		  "clockSyncUri": "",
  		  "ignoreDrmInfo": false,
  		  "disableXlinkProcessing": false,
  		  "xlinkFailGracefully": false,
  		  "ignoreMinBufferTime": false,
  		  "autoCorrectDrift": true,
  		  "initialSegmentLimit": 1000,
  		  "ignoreSuggestedPresentationDelay": true,
  		  "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,
  		  "enableAudioGroups": false,
  		  "multiTypeVariantsAllowed": true
  	  },
  	  "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,
  		  "ignoreManifestTimestampsInSegmentsMode": false,
  		  "disableCodecGuessing": false,
  		  "allowLowLatencyByteRangeOptimization": true
  	  },
  	  "mss": {
  		  "sequenceMode": false,
  		  "keySystemsBySystemId": {
  			  "9a04f079-9840-4286-ab92-e65be0885f95": "com.microsoft.playready",
  			  "79f0049a-4098-8642-ab92-e65be0885f95": "com.microsoft.playready"
  		  }
  	  }
    },
    "streaming": {
  	  "retryParameters": {
  		  "maxAttempts": 2,
  		  "baseDelay": 1000,
  		  "backoffFactor": 2,
  		  "fuzzFactor": 0.5,
  		  "timeout": 30000,
  		  "stallTimeout": 5000,
  		  "connectionTimeout": 10000
  	  },
  	  "rebufferingGoal": 6,
  	  "bufferingGoal": 30,
  	  "bufferBehind": 30,
  	  "ignoreTextStreamFailures": true,
  	  "alwaysStreamText": false,
  	  "startAtSegmentBoundary": false,
  	  "gapDetectionThreshold": 0.5,
  	  "gapJumpTimerTime": 0.25,
  	  "durationBackoff": 1,
  	  "safeSeekOffset": 5,
  	  "stallEnabled": true,
  	  "stallThreshold": 1,
  	  "stallSkip": 0.1,
  	  "useNativeHlsOnSafari": true,
  	  "inaccurateManifestTolerance": 2,
  	  "lowLatencyMode": false,
  	  "autoLowLatencyMode": false,
  	  "forceHTTPS": false,
  	  "preferNativeHls": false,
  	  "updateIntervalSeconds": 1,
  	  "dispatchAllEmsgBoxes": false,
  	  "observeQualityChanges": false,
  	  "maxDisabledTime": 30,
  	  "parsePrftBox": false,
  	  "segmentPrefetchLimit": 0,
  	  "liveSync": false,
  	  "liveSyncMaxLatency": 1,
  	  "liveSyncPlaybackRate": 1.1,
  	  "liveSyncMinLatency": 0,
  	  "liveSyncMinPlaybackRate": 1,
  	  "allowMediaSourceRecoveries": true,
  	  "minTimeBetweenRecoveries": 5
    },
    "mediaSource": {
  	  "codecSwitchingStrategy": "smooth",
  	  "sourceBufferExtraFeatures": "",
  	  "forceTransmux": false,
  	  "insertFakeEncryptionInInit": true
    },
    "offline": {
  	  "usePersistentLicense": true,
  	  "numberOfParallelDownloads": 5
    },
    "abr": {
  	  "enabled": true,
  	  "useNetworkInformation": false,
  	  "defaultBandwidthEstimate": 30099656,
  	  "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,
  	  "clearBufferSwitch": false,
  	  "safeMarginSwitch": 0
    },
    "autoShowText": 3,
    "preferredAudioLanguage": "eng",
    "preferredAudioLabel": "",
    "preferredTextLanguage": "",
    "preferredVariantRole": "",
    "preferredTextRole": "",
    "preferredAudioChannelCount": 2,
    "preferredVideoHdrLevel": "AUTO",
    "preferredVideoLayout": "",
    "preferredVideoLabel": "",
    "preferredVideoCodecs": [],
    "preferredAudioCodecs": [],
    "preferForcedSubs": false,
    "preferSpatialAudio": 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
    },
    "cmsd": {
  	  "enabled": true,
  	  "applyMaximumSuggestedBitrate": true,
  	  "estimatedThroughputWeightRatio": 0.5
    },
    "lcevc": {
  	  "enabled": false,
  	  "dynamicPerformanceScaling": true,
  	  "logLevel": 0,
  	  "drawLogo": false
    },
    "ads": {
  	  "customPlayheadTracker": false
    }
}

What did you do?

Upgraded from Shaka 3 (latest) to Shaka 4 (latest)

What did you expect to happen?

See Discussion below

What actually happened?


We were upgrading from the latest version of v3 to v4. Everything seems fine but we found out a sort of buffering delay on Live Streaming (DASH) that there wasn't before.

We use buffering event to tell the application to show and hide the UI (spinner) using buffering: true or false as the source of thruth.

this.player.addEventListener("buffering", this.onShakaBuffering_);

What is weird is that the live content starts to play but the diffence between when the play event is fired and when the buffering event is fired, can be of over 20 seconds!

As per our configuration above, we set a series of configuration parameters.

In order to attempt to reduce the buffering, we started to play with them and found out what follow:

  • manifest.defaultPresentationDelay, according to the documentation, has a default value of 1.5 * minBufferTime (which, in our manifests is of PT10S => so it would be of 15s);
  • Our manifest's maxSegmentDuration is PT4S;
  • If we set manifest.defaultPresentationDelay (which is 10 right now) below 12 (which is maxSegmentDuration * 3 (why 3?)), the buffering phase acts as described. Over 12, the buffering phase is instant and ends about with the play event;
  • We are also able to fix the behavior by turning on manifest.dash.ignoreMinbufferTime: true and without changing the values above.

As we didn't change anything else when moving from Shaka 3 to Shaka 4, what did change in this sense, under the hood? Is such behavior something to be expected?

Here below a redacted manifest of ours on which are able to reproduce the problem.

<?xml version="1.0" encoding="utf-8"?>
<MPD
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="urn:mpeg:dash:schema:mpd:2011"
  xmlns:cenc="urn:mpeg:cenc:2013"
  xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd"
  type="dynamic"
  availabilityStartTime="1970-01-01T00:00:00Z"
  publishTime="2024-05-02T14:53:22.534546Z"
  minimumUpdatePeriod="PT4S"
  timeShiftBufferDepth="PT2M"
  maxSegmentDuration="PT4S"
  minBufferTime="PT10S"
  profiles="urn:mpeg:dash:profile:isoff-live:2011,urn:com:dashif:dash264">
  <Period
    id="1"
    start="PT0S">
    <BaseURL>dash/</BaseURL>
    <AdaptationSet
      id="1"
      group="1"
      contentType="audio"
      lang="it"
      segmentAlignment="true"
      audioSamplingRate="48000"
      mimeType="audio/mp4"
      codecs="mp4a.40.5"
      startWithSAP="1">
      <AudioChannelConfiguration
        schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011"
        value="2" />
      <!-- Common Encryption -->
      <ContentProtection
        schemeIdUri="urn:mpeg:dash:mp4protection:2011"
        value="cenc"
        cenc:default_KID="<redacted>">
      </ContentProtection>
      <!-- Widevine -->
      <ContentProtection
        schemeIdUri="urn:uuid:EDEF8BA9-79D6-4ACE-A3C8-27DCD51D21ED">
      </ContentProtection>
      <Role schemeIdUri="urn:mpeg:dash:role:2011" value="main" />
      <SegmentTemplate
        timescale="48000"
        initialization="c5-dash-widevine-$RepresentationID$.dash"
        media="c5-dash-widevine-$RepresentationID$-$Time$.dash">
        <!-- 2024-05-02T14:51:18.680000Z / 1714661478 - 2024-05-02T14:53:21.560000Z -->
        <SegmentTimeline>
          <S t="82303750976640" d="184320" r="31" />
        </SegmentTimeline>
      </SegmentTemplate>
      <Representation
        id="audio_1=96000"
        bandwidth="96000">
      </Representation>
    </AdaptationSet>
    <AdaptationSet
      id="2"
      group="2"
      contentType="video"
      par="16:9"
      minBandwidth="512000"
      maxBandwidth="7000000"
      maxWidth="1920"
      maxHeight="1080"
      segmentAlignment="true"
      sar="1:1"
      frameRate="50"
      mimeType="video/mp4"
      codecs="avc1.64002A"
      startWithSAP="1">
      <!-- Common Encryption -->
      <ContentProtection
        schemeIdUri="urn:mpeg:dash:mp4protection:2011"
        value="cenc"
        cenc:default_KID="00F9F3C0-7835-36B8-CE4A-30A01A52E082">
      </ContentProtection>
      <!-- Widevine -->
      <ContentProtection
        schemeIdUri="urn:uuid:EDEF8BA9-79D6-4ACE-A3C8-27DCD51D21ED">
      </ContentProtection>
      <Role schemeIdUri="urn:mpeg:dash:role:2011" value="main" />
      <SegmentTemplate
        timescale="600"
        initialization="c5-dash-widevine-$RepresentationID$.dash"
        media="c5-dash-widevine-$RepresentationID$-$Time$.dash">
        <!-- 2024-05-02T14:51:18.680000Z / 1714661478 - 2024-05-02T14:53:21.560000Z -->
        <SegmentTimeline>
          <S t="1028796887208" d="2304" r="31" />
        </SegmentTimeline>
      </SegmentTemplate>
      <Representation
        id="video=512000"
        bandwidth="512000"
        width="512"
        height="288"
        scanType="progressive">
      </Representation>
      <Representation
        id="video=1000000"
        bandwidth="1000000"
        width="768"
        height="432"
        scanType="progressive">
      </Representation>
      <Representation
        id="video=1600000"
        bandwidth="1600000"
        width="1024"
        height="576"
        scanType="progressive">
      </Representation>
      <Representation
        id="video=2200000"
        bandwidth="2200000"
        width="1024"
        height="576"
        scanType="progressive">
      </Representation>
      <Representation
        id="video=3000000"
        bandwidth="3000000"
        width="1280"
        height="720"
        scanType="progressive">
      </Representation>
      <Representation
        id="video=3899968"
        bandwidth="3899968"
        width="1920"
        height="1080"
        scanType="progressive">
      </Representation>
      <Representation
        id="video=4800000"
        bandwidth="4800000"
        width="1920"
        height="1080"
        scanType="progressive">
      </Representation>
      <Representation
        id="video=7000000"
        bandwidth="7000000"
        width="1920"
        height="1080"
        scanType="progressive">
      </Representation>
    </AdaptationSet>
  </Period>
  <UTCTiming
    schemeIdUri="urn:mpeg:dash:utc:http-iso:2014"
    value="https://time.akamai.com/?iso" />
</MPD>

Were our observation correct? What are we doing wrong?

Can you perhaps provide us some pointers about how to configure correctly the parameters above in relation to our manifests?

Thank you very much!

@alexandercerutti alexandercerutti added the type: bug Something isn't working correctly label May 2, 2024
@shaka-bot shaka-bot added this to the v4.9 milestone May 2, 2024
@joeyparrish
Copy link
Member

Do you see the same behavior in Shaka v4.7.x? How about Shaka v4.3.x? I believe something changed regarding how we manage buffering states, though I can't recall in exactly what release branch.

@alexandercerutti
Copy link
Contributor Author

alexandercerutti commented May 3, 2024

I downgraded to ~4.3.0 and (up to v4.5.0 included) everything works as expected.
Starting from v4.6.0 the situation described starts to happen.

I suspect the changelog line involved in such change is the one discussed here below, but I'm not sure. Can you confirm it?

Anyway, @joeyparrish, do you think the described behavior can be considered as a bug?
Thank you

@joeyparrish
Copy link
Member

Yes, I think so. That is the exact change I was suspicious of.

@avelad avelad added the priority: P1 Big impact or workaround impractical; resolve before feature release label May 6, 2024
@avelad
Copy link
Collaborator

avelad commented May 6, 2024

Fixed with #6433

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: P1 Big impact or workaround impractical; resolve before feature release type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants