Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: allow for techs that init slowly in rvfc #7864

Merged
merged 2 commits into from
Sep 9, 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
2 changes: 1 addition & 1 deletion src/js/tech/tech.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
18 changes: 18 additions & 0 deletions test/unit/tech/tech.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});