Skip to content

Commit

Permalink
fix: Fix `Unable to retrieve jni environment. Is the thread attached?…
Browse files Browse the repository at this point in the history
…` errors by using `jni::ThreadScope` (#2457)

fix: Add `jni::ThreadScope` to `JVisionCameraScheduler`
  • Loading branch information
mrousavy authored Jan 30, 2024
1 parent 9089014 commit 33e2adc
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ void JVisionCameraScheduler::dispatchAsync(const std::function<void()>& job) {
}

void JVisionCameraScheduler::scheduleTrigger() {
// 2. schedule `triggerUI` to be called on the java thread
// 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());
}
Expand Down

0 comments on commit 33e2adc

Please sign in to comment.