From ceb2cd2279e06449fb4f98d7f95b39832384f0c2 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 10 Oct 2018 15:00:04 -0700 Subject: [PATCH] Handle case when OfflineAudioContext doesn't receive all the buffers --- components/script/dom/offlineaudiocontext.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/script/dom/offlineaudiocontext.rs b/components/script/dom/offlineaudiocontext.rs index 32aaa926ec9..7e967d0078a 100644 --- a/components/script/dom/offlineaudiocontext.rs +++ b/components/script/dom/offlineaudiocontext.rs @@ -151,10 +151,14 @@ impl OfflineAudioContextMethods for OfflineAudioContext { task!(resolve: move || { let this = this.root(); let processed_audio = processed_audio.lock().unwrap(); - let processed_audio: Vec<_> = processed_audio + let mut processed_audio: Vec<_> = processed_audio .chunks(this.length as usize) .map(|channel| channel.to_vec()) .collect(); + // it can end up being empty if the task failed + if processed_audio.len() != this.length as usize { + processed_audio.resize(this.length as usize, Vec::new()) + } let buffer = AudioBuffer::new( &this.global().as_window(), this.channel_count,