fix: Use ThreadScope::WithClassLoader to also load custom JNI Types (#2461)

* fix: Fix `ThreadScope` in `runAsync`

* fix: Use `&`

* Update JVisionCameraScheduler.cpp
This commit is contained in:
Marc Rousavy 2024-01-30 16:37:00 +01:00 committed by GitHub
parent 33e2adcec6
commit 9e1297531e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,10 +22,11 @@ void JVisionCameraScheduler::dispatchAsync(const std::function<void()>& job) {
void JVisionCameraScheduler::scheduleTrigger() {
// 2.1 Open a JNI Thread scope because this might be called from a C++ background Thread
jni::ThreadScope scope;
// 2.2 schedule `triggerUI` to be called on the java thread
static auto method = _javaPart->getClass()->getMethod<void()>("scheduleTrigger");
method(_javaPart.get());
jni::ThreadScope::WithClassLoader([&]() {
// 2.2 schedule `triggerUI` to be called on the java thread
static auto method = _javaPart->getClass()->getMethod<void()>("scheduleTrigger");
method(_javaPart.get());
});
}
void JVisionCameraScheduler::trigger() {