Browse Source
fix: Use revokeObjectURL dispose for created MSE blob urls (#849)
pull/923/head
Brandon Casey
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
48 additions and
1 deletions
-
src/videojs-http-streaming.js
-
test/videojs-http-streaming.test.js
|
|
@ -746,7 +746,9 @@ class VhsHandler extends Component { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this.tech_.src(window.URL.createObjectURL(this.masterPlaylistController_.mediaSource)); |
|
|
|
this.mediaSourceUrl_ = window.URL.createObjectURL(this.masterPlaylistController_.mediaSource); |
|
|
|
|
|
|
|
this.tech_.src(this.mediaSourceUrl_); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -852,6 +854,11 @@ class VhsHandler extends Component { |
|
|
|
delete this.tech_.hls; |
|
|
|
} |
|
|
|
|
|
|
|
if (this.mediaSourceUrl_ && window.URL.revokeObjectURL) { |
|
|
|
window.URL.revokeObjectURL(this.mediaSourceUrl_); |
|
|
|
this.mediaSourceUrl_ = null; |
|
|
|
} |
|
|
|
|
|
|
|
super.dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -123,6 +123,46 @@ QUnit.module('VHS', { |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
QUnit.test('mse urls are created and revoked', function(assert) { |
|
|
|
const old = { |
|
|
|
createObjectURL: window.URL.createObjectURL, |
|
|
|
revokeObjectURL: window.URL.revokeObjectURL |
|
|
|
}; |
|
|
|
const ids = []; |
|
|
|
|
|
|
|
window.URL.createObjectURL = (...args) => { |
|
|
|
const id = old.createObjectURL.apply(window.URL, args); |
|
|
|
|
|
|
|
ids.push(id); |
|
|
|
return id; |
|
|
|
}; |
|
|
|
|
|
|
|
window.URL.revokeObjectURL = (...args) => { |
|
|
|
const index = ids.indexOf(args[0]); |
|
|
|
|
|
|
|
if (index !== -1) { |
|
|
|
ids.splice(index, 1); |
|
|
|
} |
|
|
|
return old.revokeObjectURL.apply(window.URL, args); |
|
|
|
}; |
|
|
|
|
|
|
|
this.player.src({ |
|
|
|
src: 'manifest/playlist.m3u8', |
|
|
|
type: 'application/vnd.apple.mpegurl' |
|
|
|
}); |
|
|
|
|
|
|
|
this.clock.tick(1); |
|
|
|
|
|
|
|
assert.ok(ids.length > 0, 'object urls created'); |
|
|
|
|
|
|
|
this.player.dispose(); |
|
|
|
|
|
|
|
assert.equal(ids.length, 0, 'all object urls removed'); |
|
|
|
|
|
|
|
window.URL.createObjectURL = old.createObjectURL; |
|
|
|
window.URL.revokeObjectURL = old.revokeObjectURL; |
|
|
|
}); |
|
|
|
|
|
|
|
QUnit.test('version is exported', function(assert) { |
|
|
|
this.player.src({ |
|
|
|
src: 'manifest/playlist.m3u8', |
|
|
|