mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 06:15:43 +00:00
Bug 919051 - Media Recording - memory leak when record a media stream without any tracks. r=roc, r=jsmith
This commit is contained in:
parent
033860ea1f
commit
fc76c58ecb
@ -183,6 +183,12 @@ public:
|
||||
if (!mReadThread) {
|
||||
nsresult rv = NS_NewNamedThread("Media Encoder", getter_AddRefs(mReadThread));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (mInputPort.get()) {
|
||||
mInputPort->Destroy();
|
||||
}
|
||||
if (mTrackUnionStream.get()) {
|
||||
mTrackUnionStream->Destroy();
|
||||
}
|
||||
mRecorder->NotifyError(rv);
|
||||
return;
|
||||
}
|
||||
@ -363,6 +369,16 @@ MediaRecorder::Start(const Optional<int32_t>& aTimeSlice, ErrorResult& aResult)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mStream->GetPrincipal()) {
|
||||
aResult.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CheckPrincipal()) {
|
||||
aResult.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t timeSlice = 0;
|
||||
if (aTimeSlice.WasPassed()) {
|
||||
if (aTimeSlice.Value() < 0) {
|
||||
@ -373,11 +389,6 @@ MediaRecorder::Start(const Optional<int32_t>& aTimeSlice, ErrorResult& aResult)
|
||||
timeSlice = aTimeSlice.Value();
|
||||
}
|
||||
|
||||
if (!CheckPrincipal()) {
|
||||
aResult.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
mState = RecordingState::Recording;
|
||||
// Start a session
|
||||
mSession = new Session(this, timeSlice);
|
||||
|
@ -121,6 +121,7 @@ MOCHITEST_FILES = \
|
||||
test_mediarecorder_record_timeslice.html \
|
||||
test_mediarecorder_record_audiocontext.html \
|
||||
test_mediarecorder_record_stopms.html \
|
||||
test_mediarecorder_record_nosrc.html \
|
||||
test_mozHasAudio.html \
|
||||
test_source_media.html \
|
||||
test_autoplay_contentEditable.html \
|
||||
|
33
content/media/test/test_mediarecorder_record_nosrc.html
Normal file
33
content/media/test/test_mediarecorder_record_nosrc.html
Normal file
@ -0,0 +1,33 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Bug 919051 - Media Recording - memory leak when record a media stream without any tracks</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=919051">Mozill
|
||||
a Bug 919051</a>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
function startTest() {
|
||||
var mediastream = document.createElement('video').mozCaptureStream();
|
||||
|
||||
var mr = new MediaRecorder(mediastream);
|
||||
info('create MediaRecorder');
|
||||
try {
|
||||
mr.start();
|
||||
ok(false, 'should get exception');
|
||||
} catch(e) {
|
||||
is(e.name, 'InvalidStateError', "get correct exception");
|
||||
}
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
startTest();
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user