Title: newDrawable on NULL object crash in ui/styling/background.android.ts · Issue #7954 · NativeScript/NativeScript · GitHub
Open Graph Title: newDrawable on NULL object crash in ui/styling/background.android.ts · Issue #7954 · NativeScript/NativeScript
X Title: newDrawable on NULL object crash in ui/styling/background.android.ts · Issue #7954 · NativeScript/NativeScript
Description: I do not know if this is a tns-core-modules issues, an android-runtime issue, or an issue with the nativescript-mapbox plugin that I am working on. I originally filed this with the android-runtime project here: NativeScript/android#1487 ...
Open Graph Description: I do not know if this is a tns-core-modules issues, an android-runtime issue, or an issue with the nativescript-mapbox plugin that I am working on. I originally filed this with the android-runtime ...
X Description: I do not know if this is a tns-core-modules issues, an android-runtime issue, or an issue with the nativescript-mapbox plugin that I am working on. I originally filed this with the android-runtime ...
Opengraph URL: https://github.com/NativeScript/NativeScript/issues/7954
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"newDrawable on NULL object crash in ui/styling/background.android.ts","articleBody":"I do not know if this is a tns-core-modules issues, an android-runtime issue, or an issue with the nativescript-mapbox plugin that I am working on.\r\n\r\nI originally filed this with the android-runtime project here: https://github.com/NativeScript/android-runtime/issues/1487\r\n\r\n**Environment**\r\n - CLI: 6.1.2\r\n - Cross-platform modules: 6.1.1\r\n - Android Runtime: 6.1.2\r\n - iOS Runtime:\r\n - Plugin(s):\r\n\r\n```\r\n \"dependencies\": {\r\n \"@angular/animations\": \"~8.2.0\",\r\n \"@angular/common\": \"~8.2.0\",\r\n \"@angular/compiler\": \"~8.2.0\",\r\n \"@angular/core\": \"~8.2.0\",\r\n \"@angular/forms\": \"~8.2.0\",\r\n \"@angular/platform-browser\": \"~8.2.0\",\r\n \"@angular/platform-browser-dynamic\": \"~8.2.0\",\r\n \"@angular/router\": \"~8.2.0\",\r\n \"nativescript-advanced-permissions\": \"^1.2.0\",\r\n \"nativescript-mapbox\": \"file:../publish/dist/package\",\r\n \"nativescript-angular\": \"~8.2.0\",\r\n \"nativescript-theme-core\": \"~1.0.6\",\r\n \"nativescript-ui-sidedrawer\": \"~7.0.0\",\r\n \"reflect-metadata\": \"~0.1.12\",\r\n \"rxjs\": \"^6.4.0\",\r\n \"rxjs-compat\": \"^6.5.3\",\r\n \"tns-core-modules\": \"~6.1.0\",\r\n \"zone.js\": \"~0.9.1\"\r\n },\r\n \"devDependencies\": {\r\n \"@angular/compiler-cli\": \"~8.2.0\",\r\n \"@ngtools/webpack\": \"~8.2.0\",\r\n \"@types/chai\": \"~4.1.7\",\r\n \"@types/mocha\": \"~5.2.5\",\r\n \"@types/node\": \"~10.12.18\",\r\n \"chai\": \"~4.1.2\",\r\n \"codelyzer\": \"~4.5.0\",\r\n \"mocha\": \"~5.2.0\",\r\n \"mocha-junit-reporter\": \"~1.18.0\",\r\n \"mocha-multi\": \"~1.0.1\",\r\n \"mochawesome\": \"~3.1.2\",\r\n \"nativescript-dev-appium\": \"^6.1.2\",\r\n \"nativescript-dev-webpack\": \"~1.2.0\",\r\n \"node-sass\": \"^4.7.1\",\r\n \"tslint\": \"~5.19.0\",\r\n \"typescript\": \"~3.5.3\"\r\n }\r\n```\r\nUsing Android Emulator with an API 28 image under Ubuntu 18.04 LTS with Android Studio:\r\n```\r\nAndroid Studio 3.5\r\nBuild #AI-191.8026.42.35.5791312, built on August 8, 2019\r\nJRE: 1.8.0_202-release-1483-b49-5587405 amd64\r\nJVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o\r\nLinux 4.15.0-38-generic\r\n```\r\n\r\n**Describe the bug**\r\n\r\nI am working on the NativeScript Mapbox plugin. My fork is here: https://github.com/Yermo/nativescript-mapbox\r\n\r\nThe crash can be replicated using the included demo-angular app and e2e test.\r\n\r\nSince upgrading Nativescript to NS 6+, I am experiencing a random crash when navigating away from a page containing a map and removing the map container when running with \"markingMode\":\"none\".\r\n\r\nI do not know if the map plugin code is causing the instability as I have not been able to reproduce this problem navigating away from other pages, but the crash happens after the navigation has completed and the map view and object have been destroyed leading me to believe that maybe this is not my bug.\r\n\r\nThe map object is quite large so when doing lateral navigation ideally I want to destroy the mapbox view. I do this by wrapping the Mapbox tag in container with an *ngIf. Before navigating away the *ngIf condition is set to false and I wait for the mapbox onDestroy to return before proceeding with the navigation (thinking maybe there's a race condition somewhere.)\r\n\r\nAfter a random number of navigations between the map page and the test-crash page in the demo-angular app, it will crash on https://github.com/NativeScript/NativeScript/blob/430c616b938f8b78cd6b8c4917637f2d7b2aceee/tns-core-modules/ui/styling/background.android.ts#L86\r\nwhen navigating /to/ the test-crash page with the error:\r\n\r\n```\r\nJNI DETECTED ERROR IN APPLICATION: can't call android.graphics.drawable.Drawable android.graphics.drawable.ColorDrawable$ColorState.newDrawable(android.content.res.Resources) on null object\r\n```\r\n\r\ncachedDrawable in this case is not null on the javascript side so I suspect a markingMode: \"none\" issue. Adding a line of code to the javascript:\r\n```\r\nif ( cachedDrawable == null ) {\r\n\tconsole.log( \"background.android.js - cachedDrawable is NULL ---------------\" );\r\n} else {\r\n console.log( \"background.android.js - cachedDrawable is:\", cachedDrawable );\r\n}\r\n```\r\nCauses a crash on the second console.log with the error can't call toString() on null object.\r\n\r\n**To Reproduce**\r\nClone my repository:\r\n https://github.com/Yermo/nativescript-mapbox\r\n```\r\ncd nativescript-mapbox/src\r\nnpm run build.dist\r\ncd ../demo-angular\r\ntns build android\r\nnpm run e2e -- --runType android28\r\n```\r\n(or whatever emulator you have)\r\nIt will crash between 3 and 100 iterations of navigating between the map page and the crash-test page. \r\n\r\n**Expected behavior**\r\n\r\nIdeally, it should not crash.\r\n\r\n**Sample project**\r\n https://github.com/Yermo/nativescript-mapbox/demo-angular\r\n\r\n**Additional context**\r\nI am motivated to solve this problem as it is a blocking issue for me that has cost me a few weeks now. \r\nIt is entirely possible that something I am doing in my plugin is mucking up the works, but I have attempted to follow all the guides and recommendations for writing plugins. I am not the original Mapbox plugin author but am largely taking over development of that plugin. \r\n\r\nIf no one has the free cycles to look into this, could I maybe get some pointers on how I might try to track this down? \r\nIs there a way to test a NativeScript/Javascript object to see if the corresponding Java object has been freed or is set to NULL? ","author":{"url":"https://github.com/Yermo","@type":"Person","name":"Yermo"},"datePublished":"2019-10-12T21:15:22.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":15},"url":"https://github.com/7954/NativeScript/issues/7954"}
| 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:61494105-2317-a975-a243-5a2fe872ed9d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D94A:1AD267:4F6FF59:6BA972A:69731A24 |
| html-safe-nonce | 17f67c0651811300bcc39926ce15e63122ff8620850722309ee1b527e0adebc7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTRBOjFBRDI2Nzo0RjZGRjU5OjZCQTk3MkE6Njk3MzFBMjQiLCJ2aXNpdG9yX2lkIjoiNzA5NDgxNzE4MzM3NTc1OTkwOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4a583e56fe778880474c0888aa5be656e52bffb91eb52e0ae7f5195375f08d78 |
| hovercard-subject-tag | issue:506238458 |
| 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/NativeScript/7954/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cdba0093c77c93b4b3b604223a14ea73175291707cd16f4c25d1c85c3b13f3bc/NativeScript/NativeScript/issues/7954 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cdba0093c77c93b4b3b604223a14ea73175291707cd16f4c25d1c85c3b13f3bc/NativeScript/NativeScript/issues/7954 |
| og:image:alt | I do not know if this is a tns-core-modules issues, an android-runtime issue, or an issue with the nativescript-mapbox plugin that I am working on. I originally filed this with the android-runtime ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Yermo |
| hostname | github.com |
| expected-hostname | github.com |
| None | 44ab3188c1dcfe3be0f9c3feca2e04e14fb79f120939ce2395e4f15ab96ec1d4 |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/NativeScript git https://github.com/NativeScript/NativeScript.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 31492490 |
| octolytics-dimension-repository_nwo | NativeScript/NativeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31492490 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/NativeScript |
| 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 | a5e2b48bd1260476599758f5d253b5d24092ab84 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width