Skip to content

Commit

Permalink
Merge pull request #141 from margelo/fix/use-jni-classloader
Browse files Browse the repository at this point in the history
fix: Use `ThreadScope::WithClassLoader` to access custom JNI fields
  • Loading branch information
mrousavy authored Jan 30, 2024
2 parents d8dae58 + 1090c11 commit a7480c3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cpp/WKTJsiWorkletContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,12 @@ void JsiWorkletContext::invokeOnWorkletThread(
auto self = weakSelf.lock();
if (self) {
#ifdef ANDROID
facebook::jni::ThreadScope scope;
#endif
facebook::jni::ThreadScope::WithClassLoader([fp = std::move(fp), self]() {
fp(self.get(), self->getWorkletRuntime());
});
#else
fp(self.get(), self->getWorkletRuntime());
#endif
}
});
}
Expand Down

0 comments on commit a7480c3

Please sign in to comment.