NativeScript / NativeScript/nativescript-cli

NS 7 thread worker native object reference null

Open
#5,421 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.1k
Forks
204
Avg merge
1d 9h
Merged PRs (30d)
8

Description

Environment

  • CLI: 7.0.8
  • Android Runtime: 7.0.0

Describe the bug

I'm using a custom Java class to hold native objects references to share between UI thread and an worker thread, that
Worker thread with globals module imported can find and execute native code like java.lang.Thread.currentThread().getName() or my Java Class, as expected, but when its terminated and re-created throw an error and the app stops because cannot find the native objects instances to work with.

-- First time exec

JS: =================== W0: ./aeb532eaa4f320c850fc.worker.js ===================
JS: pkg: com.jnovas {
JS:   "objectpool": {}
JS: }
JS: pkg: java.lang.Thread function () { [native code] }

-- Second time exec

JS: =================== worker ===================
JS: pkg: com.jnovas {"ObjectPool":0,"objectpool":{"BuildConfig":0}}
JS: pkg: java.lang.Thread 0
JS: Uncaught TypeError: com.jnovas.ObjectPool.getInstance is not a function

Additional context
works just fine on NS 6

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 source file or test is named. Start by reproducing the worker termination and recreation sequence with the custom Java ObjectPool under NativeScript 7, then compare it with NativeScript 6; done means the recreated worker can resolve the native object references and call ObjectPool.getInstance without the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.