#550: OOM lockout kludge, alter paths + #334: remove tele from MSE

This commit is contained in:
Cameron Kaiser 2019-03-18 21:30:52 -07:00
parent 4922145621
commit 9279f48ca1
4 changed files with 31 additions and 9 deletions

View File

@ -2648,6 +2648,7 @@ HTMLMediaElement::ReportEMETelemetry()
void
HTMLMediaElement::ReportMSETelemetry()
{
#if(0)
// Report telemetry for videos when a page is unloaded. We
// want to know data on what state the video is at when
// the user has exited.
@ -2700,6 +2701,7 @@ HTMLMediaElement::ReportMSETelemetry()
Telemetry::Accumulate(Telemetry::VIDEO_MSE_JOIN_LATENCY_MS, SECONDS_TO_MS(latency));
LOG(LogLevel::Debug, ("%p VIDEO_MSE_JOIN_LATENCY = %f (%d ms) count=%d\n",
this, latency, SECONDS_TO_MS(latency), mJoinLatency.Count()));
#endif
}
void HTMLMediaElement::UnbindFromTree(bool aDeep,
@ -4236,12 +4238,14 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aPauseElement, bool aSuspendE
UpdateSrcMediaStreamPlaying();
UpdateAudioChannelPlayingState();
if (aPauseElement) {
#if(0)
if (mMediaSource) {
ReportMSETelemetry();
#ifdef MOZ_EME
ReportEMETelemetry();
#endif
}
#endif
#ifdef MOZ_EME
// For EME content, force destruction of the CDM client (and CDM

View File

@ -12,6 +12,7 @@
#include "FFmpegLog.h"
#include "FFmpegDataDecoder.h"
#include "prsystem.h"
#include "prenv.h"
#include "FFmpegRuntimeLinker.h"
#include "libavutil/pixfmt.h"
@ -248,9 +249,8 @@ FFmpegDataDecoder<LIBAV_VER>::FindAVCodec(AVCodecID aCodec)
StaticMutexAutoLock mon(sMonitor);
if (!sFFmpegInitDone) {
avcodec_register_all();
#ifdef DEBUG
av_log_set_level(AV_LOG_DEBUG);
#endif
if (PR_GetEnv("AV_LOG_DEBUG"))
av_log_set_level(AV_LOG_DEBUG);
sFFmpegInitDone = true;
}
return avcodec_find_decoder(aCodec);

View File

@ -16,6 +16,8 @@
#include "FFmpegLog.h"
#include "mozilla/PodOperations.h"
#include "prtime.h"
typedef mozilla::layers::Image Image;
typedef mozilla::layers::PlanarYCbCrImage PlanarYCbCrImage;
@ -30,6 +32,10 @@ FFmpegH264Decoder<LIBAV_VER>::PtsCorrectionContext::PtsCorrectionContext()
{
}
// PRIntervalTime is insufficient since the timeout length may be
// many seconds.
static PRTime sLockOutDueToOOM = 0L;
int64_t
FFmpegH264Decoder<LIBAV_VER>::PtsCorrectionContext::GuessCorrectPts(int64_t aPts, int64_t aDts)
{
@ -93,6 +99,12 @@ FFmpegH264Decoder<LIBAV_VER>::DecodeResult
FFmpegH264Decoder<LIBAV_VER>::DoDecodeFrame(MediaRawData* aSample)
{
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
if (PR_Now() < sLockOutDueToOOM) {
// Halt further allocations.
NS_WARNING("** FFMPEG LOCKED OUT DUE TO OUT OF MEMORY **");
mCallback->Error();
return DecodeResult::DECODE_ERROR;
}
uint8_t* inputData = const_cast<uint8_t*>(aSample->Data());
size_t inputSize = aSample->Size();
@ -140,6 +152,12 @@ FFmpegH264Decoder<LIBAV_VER>::DoDecodeFrame(MediaRawData* aSample,
uint8_t* aData, int aSize)
{
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
if (PR_Now() < sLockOutDueToOOM) {
// Halt further allocations.
NS_WARNING("** FFMPEG LOCKED OUT DUE TO OUT OF MEMORY **");
mCallback->Error();
return DecodeResult::DECODE_ERROR;
}
AVPacket packet;
av_init_packet(&packet);
@ -234,7 +252,9 @@ FFmpegH264Decoder<LIBAV_VER>::DoDecodeFrame(MediaRawData* aSample,
-1,
mImage);
if (!v) {
NS_WARNING("image allocation error.");
int32_t lockout = 3; /* XXX: make a pref */
fprintf(stderr, "Warning: TenFourFox ran out of memory trying to decode H.264 video.\nAny H.264 video on any page playing in the next %i seconds will be blocked.\n", lockout);
sLockOutDueToOOM = PR_Now() + ( PR_USEC_PER_SEC * lockout );
mCallback->Error();
return DecodeResult::DECODE_ERROR;
}

View File

@ -104,11 +104,9 @@ FFmpegRuntimeLinker::Link()
#endif
free(libFullPath);
}
// Try also finding the library in ~/Library/ffmpeg.
if (!sLinkedLib &&
PR_GetEnv("HOME") &&
asprintf(&libFullPath, "%s/Library/ffmpeg/%s", PR_GetEnv("HOME"), lib)
> 0 && libFullPath) {
// Try also finding the library in ~/Library/TenFourFox-FFmpeg.
if (!sLinkedLib && PR_GetEnv("HOME") &&
asprintf(&libFullPath, "%s/Library/TenFourFox-FFmpeg/%s", PR_GetEnv("HOME"), lib) > 0 && libFullPath) {
#if DEBUG
fprintf(stderr, "TenFourFox looking for FFmpeg: %s\n", libFullPath);
#endif