forked from mirrors/gecko-dev
Bug 1865617 - RemoteDataDecoder::Decode should handle OOM. r=geckoview-reviewers,media-playback-reviewers,owlish,jolin
According to crash data, `NewDirectByteBuffer` throws OOM exception. `RemoteDataDecoder::Decode` can return the error, so I should use fallible version of it. Differential Revision: https://phabricator.services.mozilla.com/D194199
This commit is contained in:
parent
e7e16e453b
commit
e07a314dc7
2 changed files with 24 additions and 1 deletions
|
|
@ -19,6 +19,7 @@
|
|||
#include "SimpleMap.h"
|
||||
#include "VPXDecoder.h"
|
||||
#include "VideoUtils.h"
|
||||
#include "mozilla/fallible.h"
|
||||
#include "mozilla/gfx/Matrix.h"
|
||||
#include "mozilla/gfx/Types.h"
|
||||
#include "mozilla/java/CodecProxyWrappers.h"
|
||||
|
|
@ -1019,7 +1020,11 @@ RefPtr<MediaDataDecoder::DecodePromise> RemoteDataDecoder::Decode(
|
|||
MOZ_ASSERT(GetState() != State::SHUTDOWN);
|
||||
MOZ_ASSERT(aSample != nullptr);
|
||||
jni::ByteBuffer::LocalRef bytes = jni::ByteBuffer::New(
|
||||
const_cast<uint8_t*>(aSample->Data()), aSample->Size());
|
||||
const_cast<uint8_t*>(aSample->Data()), aSample->Size(), fallible);
|
||||
if (!bytes) {
|
||||
return DecodePromise::CreateAndReject(
|
||||
MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__), __func__);
|
||||
}
|
||||
|
||||
SetState(State::DRAINABLE);
|
||||
MOZ_ASSERT(aSample->Size() <= INT32_MAX);
|
||||
|
|
|
|||
|
|
@ -976,6 +976,24 @@ class ByteBuffer : public ObjectBase<ByteBuffer, jobject> {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static LocalRef New(void* data, size_t capacity, const fallible_t&) {
|
||||
JNIEnv* const env = GetEnvForThread();
|
||||
const jobject result = env->NewDirectByteBuffer(data, jlong(capacity));
|
||||
if (env->ExceptionCheck()) {
|
||||
if (!IsOOMException(env)) {
|
||||
// This exception isn't excepted due not to OOM. This is unrecoverable
|
||||
// error.
|
||||
MOZ_CATCH_JNI_EXCEPTION(env);
|
||||
}
|
||||
#ifdef MOZ_CHECK_JNI
|
||||
env->ExceptionDescribe();
|
||||
#endif
|
||||
env->ExceptionClear();
|
||||
return LocalRef::Adopt(env, nullptr);
|
||||
}
|
||||
return LocalRef::Adopt(env, result);
|
||||
}
|
||||
|
||||
void* Address() {
|
||||
void* const ret = Env()->GetDirectBufferAddress(Instance());
|
||||
MOZ_CATCH_JNI_EXCEPTION(Env());
|
||||
|
|
|
|||
Loading…
Reference in a new issue