nativescript-vue / nativescript-vue

Native mobile applications using Vue and NativeScript.
https://nativescript-vue.org/
MIT License
5.37k stars 241 forks source link

UINavigationControllerImpl is pushing the same view controller instance #694

Open wendt88 opened 4 years ago

wendt88 commented 4 years ago

Version

2.7.0

Reproduction link

https://play.nativescript.org/?template=play-vue&id=2zRQQY

Platform and OS info

iOS

Steps to reproduce

Clone the working example, upgrade nativescript-vue to >= 2.7.0 and run it

What is expected?

the nested Frame inside sidedrawer should navigate to Content-component

What is actually happening?

Error: <UINavigationControllerImpl: 0x7fdd44039200> is pushing the same view controller instance (<UIViewControllerImpl: 0x7fdd43c2f720>) more than once which is not supported and is most likely an error in the application


It works before "nativescript-vue": "2.7.0" (<= 2.6.4)

Full stack:

***** Fatal JavaScript exception - application has been terminated. *****
Native stack trace:
1   0x10eb0462e NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool)
2   0x10eb453a8 NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*)
3   0x10f540c90 ffi_closure_unix64_inner
4   0x10f5416b2 ffi_closure_unix64
5   0x7fff48c8123e -[UIViewController _endAppearanceTransition:]
6   0x7fff48bd665d -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:]
7   0x7fff497e25b8 -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:]
8   0x7fff497e288a -[UINavigationTransitionView _cleanupTransition]
9   0x7fff498218e3 +[UIView(UIViewAnimationWithBlocks) conditionallyAnimate:withAnimation:layout:completion:]
10  0x7fff497e216c -[UINavigationTransitionView transition:fromView:toView:]
11  0x7fff48be0098 -[UINavigationController _startTransition:fromViewController:toViewController:]
12  0x7fff48be04db -[UINavigationController _startDeferredTransitionIfNeeded:]
13  0x7fff48be1820 -[UINavigationController __viewWillLayoutSubviews]
14  0x7fff48bc27f0 -[UILayoutContainerView layoutSubviews]
15  0x7fff4982d5f4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
16  0x7fff2b4e9260 -[CALayer layoutSublayers]
17  0x7fff2b4ef3eb CA::Layer::layout_if_needed(CA::Transaction*)
18  0x7fff2b4faa8a CA::Layer::layout_and_display_if_needed(CA::Transaction*)
19  0x7fff2b443a7c CA::Context::commit_transaction(CA::Transaction*, double)
20  0x7fff2b477467 CA::Transaction::commit()
21  0x7fff2b477df9 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*)
22  0x7fff23da1087 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
23  0x7fff23d9bb3e __CFRunLoopDoObservers
24  0x7fff23d9c08a __CFRunLoopRun
25  0x7fff23d9b8a4 CFRunLoopRunSpecific
26  0x7fff38c39bbe GSEventRunModal
27  0x7fff49325968 UIApplicationMain
28  0x10f5414f5 ffi_call_unix64
29  0x115cea4f0
JavaScript stack trace:
pushViewControllerAnimated(file: node_modules/@nativescript/core/ui/frame/frame.ios.js:372:61)
at file: node_modules/@nativescript/core/ui/frame/frame.ios.js:372:61
at file: node_modules/@nativescript/core/ui/frame/frame.ios.js:137:56
at file: node_modules/@nativescript/core/ui/frame/frame-common.js:300:27
at file: node_modules/@nativescript/core/ui/frame/frame-common.js:291:39
at file: node_modules/@nativescript/core/ui/frame/frame-common.js:250:8
at file: node_modules/@nativescript/core/ui/page/page.ios.js:122:42
at UIApplicationMain([native code])
at run(file: node_modules/@nativescript/core/application/application.ios.js:312:26)
at file: node_modules/nativescript-vue/dist/index.js:12636:2
at file:///app/bundle.js:291:10
at ./app.js(file:///app/bundle.js:295:34)
at __webpack_require__(file: app/webpack/bootstrap:74:0)
at checkDeferredModules(file: app/webpack/bootstrap:43:0)
at webpackJsonpCallback(file: app/webpack/bootstrap:30:0)
at anonymous(file:///app/bundle.js:2:61)
at evaluate([native code])
at moduleEvaluation([native code])
at [native code]
at asyncFunctionResume([native code])
at [native code]
at promiseReactionJob([native code])
JavaScript error:
file: node_modules/@nativescript/core/ui/frame/frame.ios.js:372:61: JS ERROR Error: <UINavigationControllerImpl: 0x7fdd44039200> is pushing the same view controller instance (<UIViewControllerImpl: 0x7fdd43c2f720>) more than once which is not supported and is most likely an error in the application : org.nativescript.playvueueue
CONSOLE WARN file: node_modules/@nativescript/core/application/application.ios.js:312:26: Fatal JavaScript exception - application has been terminated.
CONSOLE WARN file: node_modules/@nativescript/core/application/application.ios.js:312:26: Active debugger session detected. Blocking app to keep the session alive.
ok200paul commented 4 years ago

Seeing this also in an app we built, let me know if there's anything I can do to help test any proposed fixes

ok200paul commented 4 years ago

This may have something to do with iOS13.x

ok200paul commented 4 years ago

Hey @wendt88 I think I found a race condition in my code that was causing this issue - one view was in the middle of being rendered/updated when a this.$navigateTo command was run in parallel. If you're still having this problem, drop me a line and I might be able to help out.

wendt88 commented 3 years ago

Hi @ok200paul, I downgraded nativescript-vue and after a while I upgraded again and it seems to work. but now it occurs again with version 2.8.3 and iOS 14.2. can you please help me out? maybe is there something wrong in my code. THX

ok200paul commented 3 years ago

Hey @wendt88, try the following:

  1. Check If the problematic page is being programatically navigated to - say an event occurs and it triggers this view with no user input/tap. Our problem was this - an event from a data value changing was triggering a navigation, but then the user was tapping also, causing the crash.

  2. If it's definitely not number 1 above, check for events being triggered from the tap itself. It might be that the different events are trying to load two different view, or event navigating to the same view twice.

I can only really speak to my experience in this case, the problem for us appeared to be the same view being pushed twice, even though the user was only tapping once.

wendt88 commented 3 years ago

Thank you @ok200paul, I made some checks & workarounds to made it work. But I have to update my app to NS 7 and so I must upgrade nativescript-vue too. And there are some new problems I'm not able to resolve. So I created a new issue #763

wik-z commented 3 years ago

I'm currently facing the same problem and can't figure out why, with nativescript-vue v2.7.0+ and nativescript 7.0 on iOS. I've got a Frame nested within a Layout component, which adds some extra stuff, like a custom navigation bar. The frame has got an id of default and is later passed on to a router via refs. When I try to let make it navigate to the first route - no matter how many delays, $nextTicks and conditions I put in front of it, it will always throw the same error, exactly the same one that this thread talks about. I've also commented out all redirects etc. to make sure there's no additional route changes, and there isn't. The Frame crashes as soon as I try to navigate to the first page.

rigor789 commented 3 years ago

@wik-z can you share a repo that exhibits the issue? Would help tremendously with debugging it!