android: com.tns.Runtime.runWorker exception

Fatal Exception: com.tns.NativeScriptException: Cannot find runtime for id:1
       at com.tns.Runtime.runWorker(Runtime.java)
       at com.tns.Runtime.access$1500(Runtime.java:39)
       at com.tns.Runtime$WorkerThread$1.run(Runtime.java:472)
       at android.os.Handler.handleCallback(Handler.java:873)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:214)
       at android.os.HandlerThread.run(HandlerThread.java:65)

nativescript: 6.2.2 tns-core-modules: 6.2.1 tns-android: 6.2.0 tns-ios: 6.2.0

I get this crash occasionally while developing with HMR. Now, this crash is even showing up in production. It’s related to worker threads not loading as expected.

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 2
  • Comments: 23 (16 by maintainers)

Most upvoted comments

Can you try with the nativescript@next and nativescript-dev-webpack@next packages? There have been some fixes in those modules (scheduled for the 6.3 release) which should improve workers handling in HMR scenarios.

Try disabling codeCache in your app/package.json: https://github.com/NativeScript/android-runtime/issues/1554

@darind I can confirm that this crash does not occur in my project while using nativescript@next and nativescript-dev-webpack@next, moreover now the HMR is working even when there is worker in the project. Very happy with this. Closing this issue now, thank you ❤️

This is the crash I get during development

An uncaught Exception occurred on "W1: ./ffa39720cb93dc65b0d3.worker.js" thread.
Cannot find runtime for id:2

StackTrace:
	at com.tns.Runtime.runWorker(Native Method)
	at com.tns.Runtime.access$1500(Runtime.java:39)
	at com.tns.Runtime$WorkerThread$1.run(Runtime.java:472)
	at android.os.Handler.handleCallback(Handler.java:873)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:193)
	at android.os.HandlerThread.run(HandlerThread.java:65)

and on the console

System.err: An uncaught Exception occurred on "W1: ./ffa39720cb93dc65b0d3.worker.js" thread.
System.err: Cannot find runtime for id:2
System.err: 
System.err: StackTrace:
System.err:     at com.tns.Runtime.runWorker(Native Method)
System.err:     at com.tns.Runtime.access$1500(Runtime.java:39)
System.err:     at com.tns.Runtime$WorkerThread$1.run(Runtime.java:472)
System.err:     at android.os.Handler.handleCallback(Handler.java:873)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:99)
System.err:     at android.os.Looper.loop(Looper.java:193)
System.err:     at android.os.HandlerThread.run(HandlerThread.java:65)
System.err: com.tns.NativeScriptException: Cannot find runtime for id:2
System.err:     at com.tns.Runtime.passExceptionToJsNative(Native Method)
System.err:     at com.tns.Runtime.passUncaughtExceptionToJs(Runtime.java:82)
System.err:     at com.tns.NativeScriptUncaughtExceptionHandler.uncaughtException(NativeScriptUncaughtExceptionHandler.java:34)
System.err:     at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
System.err:     at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1063)
System.err:     at java.lang.Thread.dispatchUncaughtException(Thread.java:1955)

Also attaching logcat log log.txt