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

fix: No requestVideoFrameCallback on Safari with DRM #7854

Merged
merged 1 commit into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/js/tech/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -745,12 +745,15 @@ class Html5 extends Tech {

/**
* Native requestVideoFrameCallback if supported by browser/tech, or fallback
* Don't use rVCF on Safari when DRM is playing, as it doesn't fire
* Needs to be checked later than the constructor
* This will be a false positive for clear sources loaded after a Fairplay source
*
* @param {function} cb function to call
* @return {number} id of request
*/
requestVideoFrameCallback(cb) {
if (this.featuresVideoFrameCallback) {
if (this.featuresVideoFrameCallback && !this.el_.webkitKeys) {
return this.el_.requestVideoFrameCallback(cb);
}
return super.requestVideoFrameCallback(cb);
Expand All @@ -762,7 +765,7 @@ class Html5 extends Tech {
* @param {number} id request id to cancel
*/
cancelVideoFrameCallback(id) {
if (this.featuresVideoFrameCallback) {
if (this.featuresVideoFrameCallback && !this.el_.webkitKeys) {
this.el_.cancelVideoFrameCallback(id);
} else {
super.cancelVideoFrameCallback(id);
Expand Down
17 changes: 17 additions & 0 deletions test/unit/tech/html5.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1044,3 +1044,20 @@ QUnit.test('featuresVideoFrameCallback is false for audio elements', function(as

audioTech.dispose();
});

QUnit.test('featuresVideoFrameCallback is false for Safari DRM', function(assert) {
// Looking for `super.requestVideoFrameCallback()` being called
const spy = sinon.spy(Object.getPrototypeOf(Object.getPrototypeOf(tech)), 'requestVideoFrameCallback');

tech.featuresVideoFrameCallback = true;

try {
tech.el_.webkitKeys = {};
tech.requestVideoFrameCallback(function() {});

assert.ok(spy.calledOnce, false, 'rvf fallback used');
} catch (e) {
// video.webkitKeys isn't writable on Safari, so relying on the mocked property on other browsers
assert.ok(true, 'skipped because webkitKeys not writable');
}
});