Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tabs crash in 'handleTabStripChanged' when re-creating GridLayout #397

Open
chris-praxis opened this issue Jul 20, 2022 · 1 comment
Open

Comments

@chris-praxis
Copy link

Make sure to check the demo app(s) for sample usage

Make sure to check the existing issues in this repository

If the demo apps cannot help and there is no issue for your problem, tell us about it

Please, ensure your title is less than 63 characters long and starts with a capital
letter.

Which platform(s) does your issue occur on?

Android 12, possibly others

Please, provide the following version numbers that your issue occurs with:

  • CLI: 8.2.3
  • Cross-platform modules: 1.0.0
  • Runtime(s): @nativescript/android 8.2.3
  • Plugin(s):
    "dependencies": {
    "@nativescript-community/ui-material-bottom-navigation": "^7.0.25",
    "@nativescript/core": "^8.2.5",
    "@nativescript/email": "^2.0.5",
    "@nativescript/firebase": "^11.1.3",
    "@triniwiz/nativescript-youtubeplayer": "^4.1.4",
    "crypto-js": "^3.3.0",
    "fs-extra": "^10.0.1",
    "lodash.clonedeep": "^4.5.0",
    "lodash.debounce": "^4.0.8",
    "lodash.isequal": "^4.5.0",
    "lodash.merge": "^4.6.2",
    "nativescript-audio": "^6.2.6",
    "nativescript-gif": "^5.0.0",
    "nativescript-in-app-purchase": "^2.1.0",
    "nativescript-ui-gauge": "^8.0.1",
    "nativescript-ui-listview": "^10.2.0",
    "nativescript-videoplayer": "^5.0.1",
    "nativescript-vue": "^2.9.2",
    "seedrandom": "^3.0.5",
    "stacktrace-parser": "^0.1.10",
    "stacktracify": "^1.0.3"
    },
    "devDependencies": {
    "@nativescript/android": "8.2.3",
    "@nativescript/ios": "8.2.3",
    "@nativescript/webpack": "^5.0.6",
    "nativescript-vue-template-compiler": "^2.9.1"
    },

Please, tell us how to recreate the issue in as much detail as possible.

I have crash reports from users. I have not been able to reproduce, but I can see in the code how the problem can occur.

Is there any code involved?

See file: @nativescript-community/ui-material-core-tabs/tab-navigation/index.android.js

'createNativeView' calls 'handleTabStripChanged'.
Crash occurs via 'handleTabStripChanged'...
nativeView.removeView(this.mTabsBar);

'nativeView' was just created by caller, therefore it does not contain 'mTabsBar'. So if 'createNativeView' is ever called when 'mTabsBar' exists, then I expect it will crash. My hack-fix is to set "this.mTabsBar = null;" in 'createNativeView', prior to calling 'handleTabStripChanged', but I have not been able to verify.

Crash Info

Fatal Exception: com.tns.NativeScriptException
Calling js method onCreateView failed Error: java.lang.NullPointerException: Attempt to write to field 'android.view.View org.nativescript.widgets.MeasureSpecs.child' on a null object reference

Caused by java.lang.NullPointerException
Attempt to write to field 'android.view.View org.nativescript.widgets.MeasureSpecs.child' on a null object reference

handleTabStripChanged at node_modules/@nativescript-community/ui-material-core-tabs/tab-navigation/index.android.js:192:23
createNativeView at node_modules/@nativescript-community/ui-material-core-tabs/tab-navigation/index.android.js:186:17
_setupUI at node_modules/@nativescript/core/ui/core/view-base/index.js:557:30
eachChildView at node_modules/@nativescript/core/ui/content-view/index.js:65:12
eachChild at node_modules/@nativescript/core/ui/core/view/view-common.js:772:13
_setupUI at node_modules/@nativescript/core/ui/core/view-base/index.js:602:13
eachChildView at node_modules/@nativescript/core/ui/layouts/layout-base-common.js:101:27
eachChild at node_modules/@nativescript/core/ui/core/view/view-common.js:772:13
...

@chris-praxis
Copy link
Author

At least in some cases this occurs after app has been put in background and is brought back to foreground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant