nativescript-vscode-extension icon indicating copy to clipboard operation
nativescript-vscode-extension copied to clipboard

Android: app crash when using workers

Open silviudeac opened this issue 6 years ago • 5 comments

Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 6.0.3
  • Cross-platform modules: 6.0.6
  • Android Runtime: 6.0.1
  • iOS Runtime: 6.0.2

Describe the bug Using Workers on Android causes the application to crash.

The stack trace seems to indicate that the crash originates in the android-runtime:

Click to expand

adb logcat


08-22 17:16:36.280 23854 23854 I JS      : Tapped Button
08-22 17:16:36.315 23854 23932 I JS      : This code is shared between worker/app and ran from: worker
08-22 17:16:36.315 23854 23932 E v8      : 
08-22 17:16:36.315 23854 23932 E v8      : #
08-22 17:16:36.315 23854 23932 E v8      : # Fatal error in v8::HandleScope::CreateHandle()
08-22 17:16:36.315 23854 23932 E v8      : # Cannot create a handle without a HandleScope
08-22 17:16:36.315 23854 23932 E v8      : #
08-22 17:16:36.315 23854 23932 E v8      : 
08-22 17:16:36.315 23854 23932 F libc    : Fatal signal 5 (SIGTRAP), code 1 in tid 23932 (3d36a.worker.js)
08-22 17:16:36.356  1170  1170 I TrafficMonitor: update:rxPkts:4,txPkts:0,rxBytes:608,txBytes:0
08-22 17:16:36.356  1170  1170 I TrafficMonitor: start expired. level:-1
08-22 17:16:36.356  1170  1170 I TrafficMonitor: gettimer:interval=2000
08-22 17:16:36.396 24033 24033 I crash_dump64: obtaining output fd from tombstoned
08-22 17:16:36.397   778   778 I /system/bin/tombstoned: received crash request for pid 23854
08-22 17:16:36.399 24033 24033 I crash_dump64: performing dump of process 23854 (target tid = 23932)
08-22 17:16:36.400 24033 24033 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
08-22 17:16:36.400 24033 24033 F DEBUG   : Build fingerprint: 'HUAWEI/ANE-LX1/HWANE:8.0.0/HUAWEIANE-LX1/162(C432):user/release-keys'
08-22 17:16:36.400 24033 24033 F DEBUG   : Revision: '0'
08-22 17:16:36.400 24033 24033 F DEBUG   : ABI: 'arm64'
08-22 17:16:36.400 24033 24033 F DEBUG   : pid: 23854, tid: 23932, name: 3d36a.worker.js  >>> org.nativescript.webworkerdemo <<<
08-22 17:16:36.400 24033 24033 F DEBUG   : signal 5 (SIGTRAP), code 1 (TRAP_BRKPT), fault addr 0x7d0fe5bfdc
08-22 17:16:36.400 24033 24033 F DEBUG   :     x0   000000000000006b  x1   0000007cfeafc560  x2   0000000000000004  x3   0000000000000003
08-22 17:16:36.400 24033 24033 F DEBUG   :     x4   0000000040100401  x5   40404000a800a800  x6   0000000000000000  x7   7f7f7f7fff7f7f7f
08-22 17:16:36.400 24033 24033 F DEBUG   :     x8   0000000000000001  x9   a5bfd08113b6cb5e  x10  0000007cfeafc700  x11  0000000000000067
08-22 17:16:36.400 24033 24033 F DEBUG   :     x12  0000000000000038  x13  ffffffffffffffff  x14  ff00000000000000  x15  ffffffffffffffff
08-22 17:16:36.400 24033 24033 F DEBUG   :     x16  0000007d105c91f8  x17  0000007d0fe5bfc4  x18  00000000000000a2  x19  0000007d103a5a0d
08-22 17:16:36.400 24033 24033 F DEBUG   :     x20  0000007d103a59ed  x21  0000007d02a0d2c0  x22  0000007d1ebd9700  x23  0000007d1ebe2b50
08-22 17:16:36.400 24033 24033 F DEBUG   :     x24  0000000000000048  x25  0000007cf68804d1  x26  0000007d02a0d3c0  x27  0000007cee641221
08-22 17:16:36.400 24033 24033 F DEBUG   :     x28  0000007cf68804d1  x29  0000007cfeafccd0  x30  0000007d0fab67f4
08-22 17:16:36.400 24033 24033 F DEBUG   :     sp   0000007cfeafccb0  pc   0000007d0fe5bfdc  pstate 0000000060000000
08-22 17:16:36.405 24033 24033 F DEBUG   : 
08-22 17:16:36.405 24033 24033 F DEBUG   : backtrace:
08-22 17:16:36.405 24033 24033 F DEBUG   :     #00 pc 0000000000780fdc  /data/app/org.nativescript.webworkerdemo-Dnh2OJjgFtPBgtf4gJr0bw==/lib/arm64/libNativeScript.so (_ZN2v84base2OS5AbortEv+24)
08-22 17:16:36.405 24033 24033 F DEBUG   :     NativeScript/NativeScript#1 pc 00000000004fe928  /data/app/org.nativescript.webworkerdemo-Dnh2OJjgFtPBgtf4gJr0bw==/lib/arm64/libNativeScript.so (_ZN2v88internal11HandleScope6ExtendEPNS0_7IsolateE+60)
08-22 17:16:36.405 24033 24033 F DEBUG   :     NativeScript/NativeScript#2 pc 00000000004d2300  /data/app/org.nativescript.webworkerdemo-Dnh2OJjgFtPBgtf4gJr0bw==/lib/arm64/libNativeScript.so (_ZN2v88internal7Factory23NewFixedArrayWithFillerENS0_9RootIndexEiNS0_6ObjectENS0_14AllocationTypeE+260)
08-22 17:16:36.405 24033 24033 F DEBUG   :     NativeScript/NativeScript#3 pc 00000000004d4554  /data/app/org.nativescript.webworkerdemo-Dnh2OJjgFtPBgtf4gJr0bw==/lib/arm64/libNativeScript.so (_ZN2v88internal7Factory13NewFrameArrayEiNS0_14AllocationTypeE+32)
08-22 17:16:36.405 24033 24033 F DEBUG   :     NativeScript/NativeScript#4 pc 0000000000546ed0  /data/app/org.nativescript.webworkerdemo-Dnh2OJjgFtPBgtf4gJr0bw==/lib/arm64/libNativeScript.so
08-22 17:16:36.405 24033 24033 F DEBUG   :     NativeScript/NativeScript#5 pc 0000000000547500  /data/app/org.nativescript.webworkerdemo-Dnh2OJjgFtPBgtf4gJr0bw==/lib/arm64/libNativeScript.so
08-22 17:16:36.405 24033 24033 F DEBUG   :     NativeScript/NativeScript#6 pc 00000000003e7a00  /data/app/org.nativescript.webworkerdemo-Dnh2OJjgFtPBgtf4gJr0bw==/lib/arm64/libNativeScript.so (_ZN2v810StackTrace17CurrentStackTraceEPNS_7IsolateEiNS0_17StackTraceOptionsE+28)
08-22 17:16:36.405 24033 24033 F DEBUG   :     NativeScript/NativeScript#7 pc 000000000028f684  /data/app/org.nativescript.webworkerdemo-Dnh2OJjgFtPBgtf4gJr0bw==/lib/arm64/libNativeScript.so
08-22 17:16:36.405 24033 24033 F DEBUG   :     NativeScript/NativeScript#8 pc 0000000000289954  /data/app/org.nativescript.webworkerdemo-Dnh2OJjgFtPBgtf4gJr0bw==/lib/arm64/libNativeScript.so
08-22 17:16:36.406 24033 24033 F DEBUG   :     NativeScript/NativeScript#9 pc 00000000007919c8  /data/app/org.nativescript.webworkerdemo-Dnh2OJjgFtPBgtf4gJr0bw==/lib/arm64/libNativeScript.so

To Reproduce I have uploaded a sample project.

The crash occurs whenever a message is posted from the main thread to the worker outside the constructor. It is interesting that this does not replicate when posting from the constructor, but at a later date.

I have slightly modified the demo from worker-loader to reproduce the issue when tapping the button.

Expected behavior Application should not crash and worker onMessage method should execute to completion.

Sample project worker-loader.zip

silviudeac avatar Aug 22 '19 14:08 silviudeac

@silviudeacyour test application is working as expected on my side - no crash and the worker is doing its job when executed. Is the issue happening on a specific device/API level (I've tested on emulator API28) ?

NickIliev avatar Aug 23 '19 11:08 NickIliev

I tried replicating by running from CLI and to my surprise it does not replicate:

tns run android

The crash happens only when running using Visual Studio Code by using the 'Launch on Android' configuration:

        {
            "name": "Launch on Android",
            "type": "nativescript",
            "request": "launch",
            "platform": "android",
            "appRoot": "${workspaceRoot}/demo-angular",
            "sourceMaps": true,
            "watch": true
        },

Alternatively I have also replicated this by running from CLI and attaching the Visual Studio Code debugger afterwards, so it is somehow related to that though interestingly happening only on Android.

silviudeac avatar Aug 23 '19 12:08 silviudeac

@silviudeac ok it seems that debugging a worker is broken - thanks for reporting that one.

Moving the issue to the VScode repo.

NickIliev avatar Aug 23 '19 12:08 NickIliev

I am facing the same issue. My app i using workers. I can't debug it with VSCode

farfromrefug avatar Sep 20 '19 12:09 farfromrefug

news?

a92c avatar Dec 07 '21 13:12 a92c