Commit b300a0cc authored by Hongchan Choi's avatar Hongchan Choi Committed by Commit Bot

Check if AudioWorklet exists before register AudioContext

In some cases where the worklet cannot function, registering
AudioContext is not possible. (e.g. detached iframe from the document)
So BaseAudioContext needs to check the existence of worklet before
registering itself.

The fix is locally confirmed; ASAN does not crash anymore with it.

Bug: 750502
Change-Id: Id35358b0811c7f4c3476ab62e49611a8d28bad60
Reviewed-on: https://chromium-review.googlesource.com/594852
Commit-Queue: Hongchan Choi <hongchan@chromium.org>
Reviewed-by: default avatarRaymond Toy <rtoy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491070}
parent 585402b1
......@@ -171,7 +171,10 @@ void BaseAudioContext::Initialize() {
listener_ = AudioListener::Create(*this);
}
if (RuntimeEnabledFeatures::AudioWorkletEnabled()) {
// Check if a document or a frame supports AudioWorklet. If not, AudioWorklet
// cannot be accssed.
if (RuntimeEnabledFeatures::AudioWorkletEnabled() &&
WindowAudioWorklet::audioWorklet(this)) {
WindowAudioWorklet::audioWorklet(this)->RegisterContext(this);
}
}
......@@ -187,12 +190,11 @@ void BaseAudioContext::Clear() {
void BaseAudioContext::Uninitialize() {
DCHECK(IsMainThread());
if (RuntimeEnabledFeatures::AudioWorkletEnabled()) {
// AudioWorklet may be destroyed before the context goes away. So we have to
// check the pointer. See: crbug.com/503845
AudioWorklet* audioWorklet = WindowAudioWorklet::audioWorklet(this);
if (audioWorklet)
audioWorklet->UnregisterContext(this);
// AudioWorklet may be destroyed before the context goes away. So we have to
// check the pointer. See: crbug.com/503845
if (RuntimeEnabledFeatures::AudioWorkletEnabled() &&
WindowAudioWorklet::audioWorklet(this)) {
WindowAudioWorklet::audioWorklet(this)->UnregisterContext(this);
}
if (!IsDestinationInitialized())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment