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

Check |global_scope| before updating current frame in render loop

When BaseAudioContext is being tear down, AudioWorkletGlobalScope might
be already gone at that point. When BAC accesses AWGS, we must check its
existence.

Currently, the only access point of |global_scope| in BAC is
UpdateWorkletGlobalScopeOnRenderingThread().

Bug: 819845
Test: The attached repro case does not crash after 20 min run.
Change-Id: I485668708406639b8b77ae348c57c31782db5438
Reviewed-on: https://chromium-review.googlesource.com/954228Reviewed-by: default avatarRaymond Toy <rtoy@chromium.org>
Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Commit-Queue: Hongchan Choi <hongchan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541954}
parent a0ef3b78
......@@ -1019,9 +1019,14 @@ void BaseAudioContext::UpdateWorkletGlobalScopeOnRenderingThread() {
AudioWorkletGlobalScope* global_scope =
ToAudioWorkletGlobalScope(
worklet_backing_worker_thread_->GlobalScope());
DCHECK(global_scope);
global_scope->SetCurrentFrame(CurrentSampleFrame());
// When BaseAudioContext is being torn down, AudioWorkletGlobalScope might
// be already gone at this point because it's destroyed on the main thread
// but the audio thread may not have stopped. So we check |global_scope|
// before we update it.
if (global_scope) {
global_scope->SetCurrentFrame(CurrentSampleFrame());
}
}
}
......
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