From 4a45687cdabb9010c7fd0e3065fc834d23f271af Mon Sep 17 00:00:00 2001 From: JW Wang Date: Tue, 28 Jan 2014 13:41:11 +0800 Subject: [PATCH] Bug 910903 - Stop requesting data when count >= 30 to prevent the main thread from starving the encoding thread. r=jsmith --- .../test/test_mediarecorder_avoid_recursion.html | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/content/media/test/test_mediarecorder_avoid_recursion.html b/content/media/test/test_mediarecorder_avoid_recursion.html index d7cba60d6873..fd45005123e6 100644 --- a/content/media/test/test_mediarecorder_avoid_recursion.html +++ b/content/media/test/test_mediarecorder_avoid_recursion.html @@ -17,14 +17,17 @@ function startTest() { mediaRecorder.start(); info("mediaRecorder start"); mediaRecorder.ondataavailable = function (e) { - if (count++ == 30) { + ++count; + info("got ondataavailable data size = " + e.data.size); + // no more requestData() to prevent busy main thread from starving + // the encoding thread + if (count == 30) { + info("stream.stop"); stream.stop(); - } - if (mediaRecorder.state == 'recording') { - info("get data again"); + } else if (count < 30 && mediaRecorder.state == 'recording') { + info("requestData again"); mediaRecorder.requestData(); } - info("got ondataavailable data size = " + e.data.size); } mediaRecorder.requestData(); info("mediaRecorder requestData");