fix: Host Object error

This commit is contained in:
Marc Rousavy 2021-06-28 10:19:19 +02:00
parent 4a1fc1ddd8
commit e13bef7d17
2 changed files with 1 additions and 12 deletions

View File

@ -23,17 +23,7 @@ int JImageProxy::getHeight() {
} }
bool JImageProxy::getIsValid() { bool JImageProxy::getIsValid() {
static const auto getImageMethod = getClass()->getMethod<JImageProxy::javaobject()>("getImage"); return true;
auto image = getImageMethod(javaClassLocal());
static const auto getHardwareBufferMethod = findClassLocal("android/media/Image")->getMethod<jobject()>("getHardwareBuffer");
try {
getHardwareBufferMethod(image.get());
return true;
} catch (...) {
// function throws if the image is not active anymore
return false;
}
} }
int JImageProxy::getPlaneCount() { int JImageProxy::getPlaneCount() {

View File

@ -19,7 +19,6 @@ std::vector<jsi::PropNameID> FrameHostObject::getPropertyNames(jsi::Runtime& rt)
result.push_back(jsi::PropNameID::forUtf8(rt, std::string("height"))); result.push_back(jsi::PropNameID::forUtf8(rt, std::string("height")));
result.push_back(jsi::PropNameID::forUtf8(rt, std::string("bytesPerRow"))); result.push_back(jsi::PropNameID::forUtf8(rt, std::string("bytesPerRow")));
result.push_back(jsi::PropNameID::forUtf8(rt, std::string("planesCount"))); result.push_back(jsi::PropNameID::forUtf8(rt, std::string("planesCount")));
result.push_back(jsi::PropNameID::forUtf8(rt, std::string("buffer")));
return result; return result;
} }