Skip to content

Commit d736541

Browse files
authored
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.
1 parent ed4524e commit d736541

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/js/tech/tech.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ class Tech extends Component {
869869
requestVideoFrameCallback(cb) {
870870
const id = Guid.newGUID();
871871

872-
if (this.paused()) {
872+
if (!this.isReady_ || this.paused()) {
873873
this.queuedHanders_.add(id);
874874
this.one('playing', () => {
875875
if (this.queuedHanders_.has(id)) {

test/unit/tech/tech.test.js

+18
Original file line numberDiff line numberDiff line change
@@ -770,3 +770,21 @@ QUnit.test('returns an empty object for getVideoPlaybackQuality', function(asser
770770
assert.deepEqual(tech.getVideoPlaybackQuality(), {}, 'returns an empty object');
771771
tech.dispose();
772772
});
773+
774+
QUnit.test('requestVideoFrameCallback waits if tech not ready', function(assert) {
775+
const tech = new Tech();
776+
const cbSpy = sinon.spy();
777+
778+
tech.paused = sinon.spy();
779+
tech.isReady_ = false;
780+
781+
tech.requestVideoFrameCallback(cbSpy);
782+
783+
assert.notOk(tech.paused.called, 'paused not called on tech that is not ready');
784+
785+
tech.trigger('playing');
786+
787+
assert.ok(cbSpy.called, 'callback was called on tech playing');
788+
789+
tech.dispose();
790+
});

0 commit comments

Comments
 (0)