Nativescript: Crash when using iOS back button in {N} 3.1

Created on 5 Jul 2017  路  9Comments  路  Source: NativeScript/NativeScript

Did you verify this is a real problem by searching [Stack Overflow]

Yes

Tell us about the problem

After updating {N} to 3.1 (from 3.0.1) the native back button in iOS crashes, this wasn't an issue in 3.0.1 and I'm pretty sure it isn't code related since there is very little code involved. I'm using the standard {N} router with no additional code other than a programmatic router link: this.router.navigate(['/detail', selectedItems[0].id]);

Error in terminal:

1   0x10dba86db NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*)
2   0x10e27d11e ffi_closure_unix64_inner
3   0x10e27da52 ffi_closure_unix64
4   0x10efa33c3 -[UIViewController __viewWillAppear:]
5   0x10efcd3c8 -[UINavigationController _startCustomTransition:]
6   0x10efdd967 -[UINavigationController _startDeferredTransitionIfNeeded:]
7   0x10efdeb41 -[UINavigationController __viewWillLayoutSubviews]
8   0x10f1d060c -[UILayoutContainerView layoutSubviews]
9   0x10eebd55b -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
10  0x11253d904 -[CALayer layoutSublayers]
11  0x112531526 CA::Layer::layout_if_needed(CA::Transaction*)
12  0x1125313a0 CA::Layer::layout_and_display_if_needed(CA::Transaction*)
13  0x1124c0e92 CA::Context::commit_transaction(CA::Transaction*)
14  0x1124ed130 CA::Transaction::commit()
15  0x1124edb37 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*)
16  0x111fbf717 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
17  0x111fbf687 __CFRunLoopDoObservers
18  0x111fa4720 __CFRunLoopRun
19  0x111fa4016 CFRunLoopRunSpecific
20  0x114a17a24 GSEventRunModal
21  0x10edfa134 UIApplicationMain
22  0x10e27d8ad ffi_call_unix64
23  0x12e76bc60
file:///app/tns_modules/tns-core-modules/ui/core/view/view.js:263:31: JS ERROR TypeError: undefined is not an object (evaluating 'this.nativeView.hidden')
Jul  5 10:37:54 mike SpringBoard[12910]: [KeyboardArbiter] HW kbd: Failed to set (null) as keyboard focusJul  5 10:37:54 mike com.apple.CoreSimulator.SimDevice.40986AE2-0F59-42ED-9869-91EE16FDBC36.launchd_sim[12889] (UIKitApplication:com.skift.skiftApp[0xc546][12915][13315]): Service exited due to Segmentation fault: 11

Which platform(s) does your issue occur on?

iOS

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

  • CLI: 3.1
  • Cross-platform modules: 3.1.0
  • Runtime(s): Andriod: 3.1.1 iOS 3.1.0
  • Plugin(s):
    "angular/animations": "~4.1.0",
    "angular/common": "~4.1.0",
    "angular/compiler": "~4.1.0",
    "angular/core": "~4.1.0",
    "angular/forms": "~4.1.0",
    "angular/http": "~4.1.0",
    "angular/platform-browser": "~4.1.0",
    "angular/router": "~4.1.0",
    "nativescript-angular": "~3.0.0",
    "nativescript-iqkeyboardmanager": "^1.0.1",
    "nativescript-localstorage": "^1.1.5",
    "nativescript-social-share": "^1.3.2",
    "nativescript-telerik-ui": "^2.0.1",
    "nativescript-theme-core": "~1.0.2",
    "reflect-metadata": "~0.1.8",
    "rxjs": "~5.3.0",
    "tns-core-modules": "^3.1.0",
    "zone.js": "~0.8.2"

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

Add <page-router-outlet></page-router-outlet>
Add this.router.navigate(['/detail', selectedItems[0].id]);
tns run ios

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

Not that I am aware of

ios question

Most helpful comment

Ah, found the issue!

I upgraded my project using the tns upgradecommand.

I still had nativescript-angular": "~3.0.0" instead of "nativescript-angular": "~3.1.0" and "nativescript-telerik-ui": "^2.0.1" instead of "nativescript-telerik-ui": "^3.0.3" in my package.json. Upgrading Angular and nativescript-telerik-ui fixed the issue.

@mikelinden1 Did you also try to upgrade "nativescript-telerik-ui"? I think you have the same version I had to reproduce this Issue.

All 9 comments

@mikelinden1 the error does not seems to be related to the navigation and the router extensions logic.
I have created this test project demonstrating your technique here and it works as expected on both iOS and Android.

Try rebuilding your project by resetting the platforms folder and if the issue persists you can send us a sample project or snippet so we could investigate the root of the problem.

Happens in my project under iOS, too, with NativeScript 3.1.2:

This is my setup (parts of _package.json_).

  "nativescript": {
    "id": "com.foo.bar",
    "tns-android": {
      "version": "3.1.1"
    },
    "tns-ios": {
      "version": "3.1.0"
    }
  },
[...]
    "nativescript": "^3.1.2",
    "nativescript-dev-android-snapshot": "^0.*.*",
    "nativescript-dev-typescript": "^0.3.5",
    "nativescript-media-generator": "^0.2.4",

I am using the _page-router-outlet_:

<StackLayout>
    <page-router-outlet></page-router-outlet>
</StackLayout>

On Android this code is executed (works):

    goBack() {
        this.routerExtensions.back();
    }

On iOS a native back button is rendered (does not work):


Jul 11 14:10:41 --- last message repeated 25 times ---
1   0x103c606db NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*)
2   0x10433511e ffi_closure_unix64_inner
3   0x104335a52 ffi_closure_unix64
4   0x10505b3c3 -[UIViewController __viewWillAppear:]
5   0x1050853c8 -[UINavigationController _startCustomTransition:]
6   0x105095967 -[UINavigationController _startDeferredTransitionIfNeeded:]
7   0x105096b41 -[UINavigationController __viewWillLayoutSubviews]
8   0x10528860c -[UILayoutContainerView layoutSubviews]
9   0x104f7555b -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
10  0x108c2c904 -[CALayer layoutSublayers]
11  0x108c20526 CA::Layer::layout_if_needed(CA::Transaction*)
12  0x108c203a0 CA::Layer::layout_and_display_if_needed(CA::Transaction*)
13  0x108bafe92 CA::Context::commit_transaction(CA::Transaction*)
14  0x108bdc130 CA::Transaction::commit()
15  0x104eab367 _UIApplicationFlushRunLoopCATransactionIfTooLate
16  0x1056ac7a3 __handleEventQueue
17  0x1079fcc01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
18  0x1079e20cf __CFRunLoopDoSources0
19  0x1079e15ff __CFRunLoopRun
20  0x1079e1016 CFRunLoopRunSpecific
21  0x10b38da24 GSEventRunModal
22  0x104eb2134 UIApplicationMain
23  0x1043358ad ffi_call_unix64
24  0x12407df00

JS ERROR TypeError: undefined is not an object (evaluating 'this.nativeView.hidden')
````

In _view.js_:

View.prototype[style_properties_1.visibilityProperty.getDefault] = function () {
return this.nativeView.hidden ? style_properties_1.Visibility.COLLAPSE : style_properties_1.Visibility.VISIBLE;
};
```

Already cleared whole project (tns_modules, node_modules, platforms).

Happens on emulator and on real device (iOS 9 and iOS 10).

If I replace this backButton with a button without __startCustomTransition_, I can navigate.

@mikelinden1 I have created this test application trying to reproduce the issue but to no avail

The page-router-outler is here

The default page will load a list of items and on tap will redirect you to item-details page where I am navigating back using the routerExtensions.

On my side, everything works as expected - if possible take a look at the project and provide steps needed to recreate your specific scenario (or directly share a test application)

@mikelinden1 closing this due to inactivity but please do let me know if you have a test project that can reproduce the issue or if you can give me directions on how to change my test project.

I will try to reproduce this issue.

Ah, found the issue!

I upgraded my project using the tns upgradecommand.

I still had nativescript-angular": "~3.0.0" instead of "nativescript-angular": "~3.1.0" and "nativescript-telerik-ui": "^2.0.1" instead of "nativescript-telerik-ui": "^3.0.3" in my package.json. Upgrading Angular and nativescript-telerik-ui fixed the issue.

@mikelinden1 Did you also try to upgrade "nativescript-telerik-ui"? I think you have the same version I had to reproduce this Issue.

Yes, I also had 3.0.0 for angular and 2.0.1 for telerik-ui. I will try changing to see if my issue is also fixed.

I finally got around to checking on this and I can confirm that updating "nativescript-angular" to "~3.1.0" and "nativescript-telerik-ui" to "^3.0.3" resolved the issue. Thanks for the help @simonox and @NickIliev!

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings