Skip to content

Commit 33e2adc

Browse files
authored
fix: Fix Unable to retrieve jni environment. Is the thread attached? errors by using jni::ThreadScope (#2457)
fix: Add `jni::ThreadScope` to `JVisionCameraScheduler`
1 parent 9089014 commit 33e2adc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

package/android/src/main/cpp/frameprocessor/java-bindings/JVisionCameraScheduler.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ void JVisionCameraScheduler::dispatchAsync(const std::function<void()>& job) {
2121
}
2222

2323
void JVisionCameraScheduler::scheduleTrigger() {
24-
// 2. schedule `triggerUI` to be called on the java thread
24+
// 2.1 Open a JNI Thread scope because this might be called from a C++ background Thread
25+
jni::ThreadScope scope;
26+
// 2.2 schedule `triggerUI` to be called on the java thread
2527
static auto method = _javaPart->getClass()->getMethod<void()>("scheduleTrigger");
2628
method(_javaPart.get());
2729
}

0 commit comments

Comments
 (0)