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

Preload does not use NetworkingEngine configuration #6616

Closed
mathix420 opened this issue May 15, 2024 · 5 comments
Closed

Preload does not use NetworkingEngine configuration #6616

mathix420 opened this issue May 15, 2024 · 5 comments
Labels
status: unable to reproduce Issue could not be reproduced by the team type: bug Something isn't working correctly
Milestone

Comments

@mathix420
Copy link

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

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

What version of Shaka Player are you using? 4.8.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? Custom app

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

What browser and OS are you using? Chrome & Linux

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": {},
    "clearKeys": {},
    "advanced": {},
    "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": 0,
    "segmentRelativeVttTiming": false,
    "raiseFatalErrorOnManifestUpdateRequestFailure": 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"
      },
      "sequenceMode": false,
      "enableAudioGroups": false,
      "multiTypeVariantsAllowed": true,
      "useStreamOnceInPeriodFlattening": false,
      "updatePeriod": -1
    },
    "hls": {
      "ignoreTextStreamFailures": false,
      "ignoreImageStreamFailures": false,
      "defaultAudioCodec": "mp4a.40.2",
      "defaultVideoCodec": "avc1.42E01E",
      "ignoreManifestProgramDateTime": false,
      "ignoreManifestProgramDateTimeForTypes": [],
      "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": 2,
    "bufferingGoal": 10,
    "bufferBehind": 30,
    "evictionGoal": 1,
    "ignoreTextStreamFailures": false,
    "alwaysStreamText": false,
    "startAtSegmentBoundary": false,
    "gapDetectionThreshold": 0.5,
    "gapJumpTimerTime": 0.25,
    "durationBackoff": 1,
    "safeSeekOffset": 5,
    "stallEnabled": true,
    "stallThreshold": 1,
    "stallSkip": 0.1,
    "useNativeHlsOnSafari": true,
    "useNativeHlsForFairPlay": true,
    "inaccurateManifestTolerance": 2,
    "lowLatencyMode": false,
    "autoLowLatencyMode": false,
    "forceHTTPS": false,
    "preferNativeHls": false,
    "updateIntervalSeconds": 1,
    "dispatchAllEmsgBoxes": false,
    "observeQualityChanges": false,
    "maxDisabledTime": 30,
    "parsePrftBox": false,
    "segmentPrefetchLimit": 0,
    "prefetchAudioLanguages": [],
    "disableAudioPrefetch": false,
    "disableTextPrefetch": false,
    "disableVideoPrefetch": false,
    "liveSync": false,
    "liveSyncMaxLatency": 1,
    "liveSyncPlaybackRate": 1.1,
    "liveSyncMinLatency": 0,
    "liveSyncMinPlaybackRate": 1,
    "liveSyncPanicMode": false,
    "liveSyncPanicThreshold": 60,
    "allowMediaSourceRecoveries": true,
    "minTimeBetweenRecoveries": 5,
    "vodDynamicPlaybackRate": false,
    "vodDynamicPlaybackRateLowBufferRate": 0.95,
    "vodDynamicPlaybackRateBufferRatio": 0.5,
    "infiniteLiveStreamDuration": false
  },
  "mediaSource": {
    "codecSwitchingStrategy": "smooth",
    "forceTransmux": false,
    "insertFakeEncryptionInInit": true
  },
  "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,
    "clearBufferSwitch": false,
    "safeMarginSwitch": 0
  },
  "autoShowText": 3,
  "preferredAudioLanguage": "",
  "preferredAudioLabel": "",
  "preferredTextLanguage": "",
  "preferredVariantRole": "",
  "preferredTextRole": "",
  "preferredAudioChannelCount": 2,
  "preferredVideoHdrLevel": "AUTO",
  "preferredVideoLayout": "",
  "preferredVideoLabel": "",
  "preferredVideoCodecs": [
    "vp09",
    "avc1"
  ],
  "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,
  "textDisplayer": {
    "captionsUpdatePeriod": 0.25
  },
  "cmcd": {
    "enabled": false,
    "sessionId": "",
    "contentId": "",
    "rtpSafetyFactor": 5,
    "useHeaders": false,
    "includeKeys": []
  },
  "cmsd": {
    "enabled": true,
    "applyMaximumSuggestedBitrate": true,
    "estimatedThroughputWeightRatio": 0.5
  },
  "lcevc": {
    "enabled": false,
    "dynamicPerformanceScaling": true,
    "logLevel": 0,
    "drawLogo": false
  },
  "ads": {
    "customPlayheadTracker": false,
    "skipPlayDetection": false
  }
}

What did you do?

// Hardcoded for demo purposes
const bestMomentTimecode = 55 // Best moment of the video is at 55s
const isAppleShit = false
const videoUrl = 'https://storage.googleapis.com/shaka-demo-assets/bbb-dark-truths-hls/hls.m3u8'

const player = new shaka.Player()

await player.attach(document.getElementById('video'))

player.getNetworkingEngine().registerRequestFilter(function (_type, request) {
  if (isAppleShit) request.allowCrossSiteCredentials = true
  else request.headers.Authorization = 'Some Access Token'
})

player.configure('preferredVideoCodecs', ['vp09', 'avc1'])

if (bestMomentTimecode) {
  try {
    // I know this is not correctly implemented to actually preload the video
    // but preload requests should still be passing the Authorization header which they are not
    await player.preload(videoUrl, bestMomentTimecode)
  } catch (error) {
    console.error('Failed to preload', error)
  }
}

await player.load(videoUrl)

What did you expect to happen?

Preload requests should have the Authorization header (just like usual requests).

What actually happened?

Preload requests didn't had the Authorization header.

Are you planning send a PR to fix it?

No, sorry.

@mathix420 mathix420 added the type: bug Something isn't working correctly label May 15, 2024
@mathix420 mathix420 changed the title Preload does not use main NetworkingEngine configuration Preload does not use NetworkingEngine configuration May 15, 2024
@shaka-bot shaka-bot added this to the v4.9 milestone May 15, 2024
@theodab
Copy link
Collaborator

theodab commented May 16, 2024

I tried running your code segment in the demo app, and the network requests for the manifest had an Authorization header of "Some Access Token".
This happened both with the v4.8.4 demo, and the nightly demo.
I tested on a MacOS and a Windows computer, so perhaps this might be a Linux specific issue somehow.

From a code standpoint, I'm not really sure what would cause this. The preload manager uses the networking engine of the player instance, and thus would use the request filters defined on the player.

@avelad avelad added the status: waiting on response Waiting on a response from the reporter(s) of the issue label May 16, 2024
@joeyparrish joeyparrish added the status: unable to reproduce Issue could not be reproduced by the team label May 16, 2024
@mathix420
Copy link
Author

Thanks @theodab! That's interesting, I'll have a deeper look next week and let you know if I can find more insights

@shaka-bot shaka-bot removed the status: waiting on response Waiting on a response from the reporter(s) of the issue label May 16, 2024
@avelad avelad added the status: waiting on response Waiting on a response from the reporter(s) of the issue label May 16, 2024
@shaka-bot
Copy link
Collaborator

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.

@shaka-bot shaka-bot removed the status: waiting on response Waiting on a response from the reporter(s) of the issue label May 23, 2024
@jimmymic
Copy link

jimmymic commented May 27, 2024

@mathix420 did you get to the bottom of this?
We are seeing something similar - manifest appears to be ok, but the segments do not have the correct request filter applied.

@jason-s13r
Copy link

@shaka-bot reopen

This is in reference to @jimmymic's comment above.

We've been having trouble with shaka.media.PreloadManager not sending cookies with preload requests despite the player's networking engine having a request filter to set request.allowCrossSiteCredentials = true.

I believe that this is due to the shaka.Player.makePreloadManager_ creating a networking engine for the preload manager. https://github.com/shaka-project/shaka-player/blob/c541515995f630573fa545f8478e65fb15585019.
const networkingEngine = this.createNetworkingEngine(getPreloadManager);

This new networking engine has empty sets for requestFilters_ and responseFilters_ for the preload manager.

I think a PreloadManager should expose a getNetworkingEngine(), and/or copy the sets from the player's networking engine, or use the same networking engine.

Using the Shaka demo website with uncompiled v4.8.7, I can use in the JS console:

const player = new shaka.Player();
await player.attach(document.getElementById('video'));

player.getNetworkingEngine().registerRequestFilter(function (_type, request) {
  request.uris = request.uris.map(uri => uri + (uri.includes('?') ? '&' : '?') + '__viaRequestFilter=true');
});

const manager = await player.preload(shakaAssets.testAssets[1].manifestUri);
manager.networkingEngine_.registerRequestFilter(function (_type, request) {
  request.uris = request.uris.map(uri => uri + (uri.includes('?') ? '&' : '?') + '__preload=true');
});


const manager2 = await player.preload(shakaAssets.testAssets[1].manifestUri);

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: unable to reproduce Issue could not be reproduced by the team type: bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

7 participants