You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Crash on navigate on app resume: The specified child already has a parent #6708
Describe the bug
Navigating to a page when app resumes from background causes the app to crash with the following exception:
An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to resume activity {org.nativescript.bl32/com.tns.NativeScriptActivity}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3103)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1388)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
To Reproduce
Create app from blank template
Add new Page second-page.xml
Add the following application.resumeEvent handler to app.ts:
@nudiref as a workaround you can wrap the navigate action inside a setTimeout(...) call with 0ms delay and that should allow you to achieve the desired effect:
Instead of:
Side drawer as root with an observable variable as defaultPage <Frame defaultPage="{{ startPage }}"></Frame>
If my user is logged then defaultPage is set with a home page, otherwise defaultPage becomes the login page.
For me the issue happens when I navigate from login to home page, navigates back to login and then open another app. When I back to my app, the crash happens.
Wrapping my navigate functions inside setTimeout did not work, but I figured out that removing the observable from defaultPage and setting directly a page, defaultPage="login/login-page", the issue stops.
Is my structure correct? Is there other way to achive the auto-login funcionality with a side drawer as root?
when I navigate from login to home page, navigates back to login and then open another app.
Usually when navigating from login screen you would set clearHistory to true as user should not be able to return to login screen unless he/she decides to log out?
Find attached a modified version of the drawer navigation template that implements such login/logout functionality with observable defaultPage property binding.
@nudiref as a workaround you can wrap the navigate action inside a setTimeout(...) call with 0ms delay and that should allow you to achieve the desired effect:
Instead of:
@nudiref as a workaround you can wrap the navigate action inside a setTimeout(...) call with 0ms delay and that should allow you to achieve the desired effect:
Instead of:
Activity
manoldonev commentedon Dec 14, 2018
@nudiref as a workaround you can wrap the
navigateaction inside a setTimeout(...) call with 0ms delay and that should allow you to achieve the desired effect:Instead of:
Use:
wagnerlino commentedon Dec 15, 2018
Hi @manoldonev,
In my project I have the following structure:
Side drawer as root with an observable variable as defaultPage
<Frame defaultPage="{{ startPage }}"></Frame>If my user is logged then defaultPage is set with a home page, otherwise defaultPage becomes the login page.
For me the issue happens when I navigate from login to home page, navigates back to login and then open another app. When I back to my app, the crash happens.
Wrapping my navigate functions inside setTimeout did not work, but I figured out that removing the observable from defaultPage and setting directly a page,
defaultPage="login/login-page", the issue stops.Is my structure correct? Is there other way to achive the auto-login funcionality with a side drawer as root?
manoldonev commentedon Dec 17, 2018
Usually when navigating from login screen you would set
clearHistoryto true as user should not be able to return to login screen unless he/she decides to log out?Find attached a modified version of the drawer navigation template that implements such login/logout functionality with observable
defaultPageproperty binding.bl33.zip
nudiref commentedon Dec 18, 2018
thanks for the info and workaround Manol. i hope there will be a fix soon
vosonha89 commentedon Jan 11, 2019
It worked for me :). Thank you so much
lock commentedon Jan 11, 2020
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.