NativeScript / NativeScript/napi-android

Add ability to Share Native Object Instances between Main and Worker Runtimes

Open
#37 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
33
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Both Worker and Main JS runtime instances use the same Java environment hence the native objects can be shared between the two.
Main:

const nativeObject = new java.lang.String("string");
const worker = new Worker(...);
worker.postMessage({
  myNativeString: globalThis.createNativeHandle(nativeObject)
});

Worker:

globalThis.onmessage = (message) => {
  const nativeObject = globalThis.resolveNativeHandle(message.myNativeString);
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by tracing the Main and Worker runtime message paths around the shown createNativeHandle and resolveNativeHandle entry points, then determine how a Java-backed object can remain valid across runtimes. Done means the example can send a native String from Main to Worker and resolve it there safely.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, cpp, java, javascript, typescript
Domain
mobile-dev, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.