From 7d8a6f8cdb9eb65e193a7a23661282133e66a9b6 Mon Sep 17 00:00:00 2001 From: mister-ben Date: Fri, 9 Sep 2022 19:52:34 +0200 Subject: [PATCH] fix: allow for techs that init slowly in rvfc (#7864) Don't call tech.paused() in the requestVideoFrameCallback fallback if the tech is not ready. I've seen this is an issue in the Flash tech, as its methods are set up after the swf loads. Yes, Flash, it's 2022, but in theory another tech could be impacted if it's also async. --- src/js/tech/tech.js | 2 +- test/unit/tech/tech.test.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/js/tech/tech.js b/src/js/tech/tech.js index 31c81cc646..d0c68e5fb7 100644 --- a/src/js/tech/tech.js +++ b/src/js/tech/tech.js @@ -869,7 +869,7 @@ class Tech extends Component { requestVideoFrameCallback(cb) { const id = Guid.newGUID(); - if (this.paused()) { + if (!this.isReady_ || this.paused()) { this.queuedHanders_.add(id); this.one('playing', () => { if (this.queuedHanders_.has(id)) { diff --git a/test/unit/tech/tech.test.js b/test/unit/tech/tech.test.js index 4dc4e51b04..57fca449df 100644 --- a/test/unit/tech/tech.test.js +++ b/test/unit/tech/tech.test.js @@ -770,3 +770,21 @@ QUnit.test('returns an empty object for getVideoPlaybackQuality', function(asser assert.deepEqual(tech.getVideoPlaybackQuality(), {}, 'returns an empty object'); tech.dispose(); }); + +QUnit.test('requestVideoFrameCallback waits if tech not ready', function(assert) { + const tech = new Tech(); + const cbSpy = sinon.spy(); + + tech.paused = sinon.spy(); + tech.isReady_ = false; + + tech.requestVideoFrameCallback(cbSpy); + + assert.notOk(tech.paused.called, 'paused not called on tech that is not ready'); + + tech.trigger('playing'); + + assert.ok(cbSpy.called, 'callback was called on tech playing'); + + tech.dispose(); +});