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

Clear and encrypted periods working shaka 3.x and not 4.x #4512

Closed
jakubvojacek opened this issue Sep 26, 2022 · 5 comments · Fixed by #4606
Closed

Clear and encrypted periods working shaka 3.x and not 4.x #4512

jakubvojacek opened this issue Sep 26, 2022 · 5 comments · Fixed by #4606
Assignees
Labels
component: DASH The issue involves the MPEG DASH manifest format priority: P1 Big impact or workaround impractical; resolve before feature release status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Milestone

Comments

@jakubvojacek
Copy link

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

What version of Shaka Player are you using?
4.2.1 and 3.3.10

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?
Our license server is too complicated to be used withing the demo app

What browser and OS are you using?
Mac 12.4

  • works in FF 104.0.2
  • works in exoplayer
  • does not work in Chrome 105.0.5195.125

What did you do?
Below is the source code for demo app. It has 2 JS included, one commented out. This sample works for both 4.x and 3.x in FF. In chrome it works only with 3.x version.

The sample includes content as well as widevine URL.

<!DOCTYPE html>
<html>
<head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/shaka-player/4.2.1/shaka-player.compiled.debug.min.js"></script>
<!--    <script src="https://cdnjs.cloudflare.com/ajax/libs/shaka-player/3.3.10/shaka-player.compiled.debug.min.js" integrity="sha512-uNvwR4nTxy6kLMZb8c2LO573kEjp7KNqtMcS12ZtcjH0ciWSxUdJjCzI2B7TVhmEXyM+CpbrkfQ9/ZLtPAUhPw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>-->
</head>
<body>
<video id="video"controls autoplay></video>
<script type="text/javascript">
    function initApp() {
        shaka.polyfill.installAll();

        var video = document.getElementById('video');
        var player = new shaka.Player(video);

        player.configure({
            drm: {
                servers: {
                    'com.widevine.alpha': 'https://mw.motv.eu/widevine_proxy',
                }
            }
        });

        var devices_type = 'web player';
        var devices_identification = 'mac os, chrome';
        var devices_hash = 'nfihi!knkn1123...unique';
        var customers_token = 'q34rmp2fn99glgpwbx0gf8pkfakigyjizttlewvi';
        var profiles_id = '104565';
        var version = '0.1';
        var timestamp = parseInt(new Date().getTime() / 1000);
        var offset = 0;
        var edges_id = 1;

        player.getNetworkingEngine().registerRequestFilter(function(type, request) {
            var StringUtils = shaka.util.StringUtils;
            var Uint8ArrayUtils = shaka.util.Uint8ArrayUtils;

            if (type == shaka.net.NetworkingEngine.RequestType.LICENSE) {
                request.headers['Authorization'] = 'Bearer ' + customers_token;
                request.headers['profilesId'] = btoa(profiles_id);
                request.headers['devicesType'] = btoa(devices_type);
                request.headers['version'] = btoa(version);
                request.headers['browserType'] = btoa('chrome');
                var wrapped = {};
                wrapped.timestamp = timestamp;
                wrapped.offset = offset;
                wrapped.edges_id = edges_id;
                wrapped.devices_identification = devices_identification;
                wrapped.devices_hash = devices_hash;
                wrapped.rawLicense =
                    Uint8ArrayUtils.toBase64(new Uint8Array(request.body), false);

                var wrappedJson = JSON.stringify(wrapped);
                request.body = StringUtils.toUTF8(wrappedJson);
            }
        });
        player.getNetworkingEngine().registerResponseFilter(function(type, response) {
            var StringUtils = shaka.util.StringUtils;
            var Uint8ArrayUtils = shaka.util.Uint8ArrayUtils;

            if (type == shaka.net.NetworkingEngine.RequestType.LICENSE) {
                var wrappedString = StringUtils.fromUTF8(response.data);
                var wrapped = JSON.parse(wrappedString);
                var rawLicense = wrapped.rawLicense;
                response.data = Uint8ArrayUtils.fromBase64(rawLicense);
            }
        });

        player.load('https://edge1.cico.tv/s1/vods/test.mpd');
        video.play();
    }
    document.addEventListener('DOMContentLoaded', initApp);
</script>
</body>
</html>

What did you expect to happen?
For the playback to work with shaka 4.x in chrome.

What actually happened?
It does not play in Chrome with 4.x version. The error I see in JS console is

(video:4) failed fetch and append: code=3014

with no further information. I think it might be something related to encryption. If I package the same content without encryption, just clear content, it plays in Chrome too.

Can you please try it out and tell us what might be wrong with he MPD? Or is it content OK and the issue is in shaka 4.x?

Thanks a lot

@jakubvojacek jakubvojacek added the type: bug Something isn't working correctly label Sep 26, 2022
@github-actions github-actions bot added this to the v4.3 milestone Sep 26, 2022
@jakubvojacek
Copy link
Author

jakubvojacek commented Sep 27, 2022

I did read few other issues such as #2566

  • there are no logs in chrome://gpu/
  • tried disabling Hardware-accelerated video decode/encode - no change

I have used chrome://media-internals/ to capture the log for both shaka 4.2.1 and 3.3.10

media-internals-failed-4.2.1.txt
media-internals-works-3.3.10.txt

I tried 4.0.0 and it didnt work either. I guess something period-related must have changed in between 3.3.10 and 4.2.1. But when checking changelog of 4.0.0 I didnt find any multiperiod related note

@jakubvojacek
Copy link
Author

I managed to identify the commit that broke the playback (by checking individual commits in between 3 and 4 and building the player).

Commit 7155ec7 from Feb 4th works
Next commit 6d76a13 from the next day from @valotvince - does not work.

Unfortunately, I am not really familiar with JS to do more thorough checks of the code to identify which block of new code is responsible.

Any help highly appreciated please!

@avelad avelad added the component: DASH The issue involves the MPEG DASH manifest format label Sep 27, 2022
@dk00
Copy link

dk00 commented Oct 14, 2022

It should be related to when MediaKeys object is attached to the video.

In 3.x.x, MediaKeys when loading a stream, but starting from 6d76a13, MediaKeys object is attached when encrypted event is fired, and maybe too late for Chrome.

In media-internals log, Chrome said: Failed to initialize DecryptingVideoDecoder.

      {
        "time": 28.13099992275238,
        "key": "info",
        "value": "Failed to initialize DecryptingVideoDecoder"
      },
      {
        "time": 34.519999980926514,
        "key": "kIsVideoDecryptingDemuxerStream",
        "value": false
      },

@avelad @joeyparrish , is this a Chrome bug? or is it good idea to revert MediaKeys object attachment behavior, attach it when initialization instead of first encrypted event?

I was able to workaround by adding window.shakaMediaKeysPolyfill = true right before player init, @jakubvojacek does this work for you?

 var video = document.getElementById('video');
+window.shakaMediaKeysPolyfill = true;
 var player = new shaka.Player(video);

@avelad avelad added the priority: P1 Big impact or workaround impractical; resolve before feature release label Oct 14, 2022
@jakubvojacek
Copy link
Author

Hello

yes, I can confirm that with window.shakaMediaKeysPolyfill = true; it works as expected. Thank you a lot!

@avelad
Copy link
Member

avelad commented Oct 23, 2022

I created a PR #4606

@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Dec 24, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: DASH The issue involves the MPEG DASH manifest format priority: P1 Big impact or workaround impractical; resolve before feature release 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