Title: Android worker crash since tns-android 6.3.0 · Issue #1602 · NativeScript/android · GitHub
Open Graph Title: Android worker crash since tns-android 6.3.0 · Issue #1602 · NativeScript/android
X Title: Android worker crash since tns-android 6.3.0 · Issue #1602 · NativeScript/android
Description: 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.5.1 Cross-platform modules: 6.5.0 Android...
Open Graph Description: 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.5...
X Description: 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.5...
Opengraph URL: https://github.com/NativeScript/android/issues/1602
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Android worker crash since tns-android 6.3.0","articleBody":"**Environment**\r\nProvide 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):\r\n - CLI: 6.5.1\r\n - Cross-platform modules: 6.5.0\r\n - Android Runtime: 6.5.0 (also reproducable on 6.4.1)\r\n - iOS Runtime (if applicable): -\r\n - Plugin(s): nativescript-dev-webpack 1.5.1\r\n\r\n**Describe the bug**\r\nWhen starting a worker script for the second time on an Androd 9 / 10 physical device, the worker thread throws an exception and most times, the app crashes as well.\r\n\r\nPlease note\r\n- it seems to be reproducable only on a physical device with Android 9 or 10, it does not occur on any Android emulator and on device with older Android version\r\n- everything was working as expected using tns-android 6.3.1 (issue occurs after upgrading to 6.4.1 or 6.5.0) --> **update:** 6.4.0 is the latest android runtime version without that bug!\r\n- we reproduce this issue on our Google Pixel 3a (Android 10) and on our Nokia 5.1 (Android 9)\r\n- the issue does not occur on our Nexus 4 (Android 5.1), Moto X Play (Android 7.1) and Moto Z Play (Android 8.0)\r\n\r\nWhat we are doing in the demo app provided below\r\nOn button tap we call this:\r\n\r\n```\r\nconst WorkerScript = require(\"nativescript-worker-loader!./myworker\");\r\nconst worker = new WorkerScript();\r\n\r\nworker.onmessage = function(msg) {\r\n if(msg.data.isWorkerLoaded) {\r\n console.log(\"#### worker notify state 'loaded' -> start action...\");\r\n\r\n worker.postMessage({\r\n action: \"test\"\r\n });\r\n } else if(msg.data.hasOwnProperty('success')) {\r\n console.log(\"#### worker success\");\r\n\r\n worker.terminate();\r\n\r\n alert(\"Worker success\");\r\n }\r\n};\r\n\r\nworker.onerror = function(e) {\r\n console.log(\"#### worker onerror: \", e);\r\n worker.terminate();\r\n\r\n alert(\"Worker onerror\");\r\n};\r\n```\r\n\r\nAnd that's the worker script:\r\n```\r\n//myworker.js\r\n\r\nrequire(\"@nativescript/core/globals\");\r\n\r\n//notify main-thread about worker being loaded\r\nglobal.postMessage({isWorkerLoaded: true});\r\n\r\n\r\nglobal.onmessage = function(msg) {\r\n if(msg.data.action === \"test\") {\r\n setTimeout(function() {\r\n global.postMessage({ success: true });\r\n }, 3000);\r\n }\r\n};\r\n```\r\n\r\n\r\n**To Reproduce**\r\n1.) Start the demo app provided below (on Android 9 or 10 **physical device**)\r\n2.) Tap the button, wait some short time and you see the alert \"Worker success\"\r\n3.) Tapping the button for a second time should also alert \"Worker success\", but instead it crashes the app\r\n\r\n4.) \r\n```\r\ntns platform remove android\r\ntns platform add android@6.4.0\r\ntns run android\r\n```\r\n\r\n5.) repeat steps 1-3 and you see that the app won't crash anymore.\r\n\r\n**Expected behavior**\r\nYou should be able to start and terminate this worker script as often as you want, like it was working until tns-android **6.3.1**\r\n\r\n\r\n**Sample project**\r\n[ns-worker-issue-android10.zip](https://github.com/NativeScript/android-runtime/files/4475142/ns-worker-issue-android10.zip)","author":{"url":"https://github.com/felixkrautschuk","@type":"Person","name":"felixkrautschuk"},"datePublished":"2020-04-14T12:18:54Z","url":"https://github.com/NativeScript/android/issues/1602"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1c59dd64-a40d-359d-0a77-b0ba089721db |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9562:96DDF:1BA665F:2300DAD:6B014D64 |
| html-safe-nonce | 56a7cb4e034f45923886f372e1fdc77218f18fc4ab1976dfbadba21011c6cc74 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTYyOjk2RERGOjFCQTY2NUY6MjMwMERBRDo2QjAxNEQ2NCIsInZpc2l0b3JfaWQiOiI2MTA5NTc3ODkzNTg5ODk2NTQ5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 848d75836b21979af139f16cb665424ccca5474fc0696a64393c12bb3b1eebcf |
| hovercard-subject-tag | issue:599530288 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NativeScript/android/1602/issue_layout |
| twitter:image | https://opengraph.githubassets.com/57c82603a608e19531107f52f5a146a4b0035183b3bea856e9fbaddb7f8f39c7/NativeScript/android/issues/1602 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/57c82603a608e19531107f52f5a146a4b0035183b3bea856e9fbaddb7f8f39c7/NativeScript/android/issues/1602 |
| og:image:alt | 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.5... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | felixkrautschuk |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/android git https://github.com/NativeScript/android.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 29137950 |
| octolytics-dimension-repository_nwo | NativeScript/android |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 29137950 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/android |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width