Repository navigation
Open
NativeScript/NativeScript
#8879Description
Environment
- CLI: 7.0.7
- Android Runtime: 7.0.0
- iOS Runtime: 7.0.0
- NativeScript-Angular: 10.1.3
- Angular: 10.1.0
Describe the bug
I have a dialog which has 2 tabs inside it. When I try to dismiss the dialog by tapping the dialog overlay (dark transparent area) or by pressing back button, this exception occurs:
System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method destroyItem failed
System.err: Error: java.lang.IllegalStateException: Cannot detach Fragment attached to a different FragmentManager. Fragment FragmentBase_vendor_135144_28_TabFragmentImplementation{f89a49e} (2f3646ad-0ab5-459a-9c9e-20f4ee91cb19) id=0xd android:viewpager:13:0} is already attached to a FragmentManager.
System.err:
System.err: StackTrace:
System.err: FragmentPagerAdapter.destroyItem(file: node_modules/@nativescript/core/ui/tabs/index.android.js:159:0)
System.err: at setItems(file: node_modules/@nativescript/core/ui/tabs/index.android.js:478:0)
System.err: at onUnloaded(file: node_modules/@nativescript/core/ui/tabs/index.android.js:412:0)
System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:300:0)
System.err: at callFunctionWithSuper(file: node_modules/@nativescript/core/ui/core/view-base/index.js:291:0)
System.err: at callUnloaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:300:0)
System.err: at unloadView(file: node_modules/@nativescript/core/ui/core/view-base/index.js:445:0)
System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:228:0)
System.err: at eachChildView(file: node_modules/@nativescript/core/ui/layouts/layout-base-common.js:101:0)
System.err: at eachChild(file: node_modules/@nativescript/core/ui/core/view/view-common.js:700:0)
System.err: at onUnloaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:227:0)
System.err: at onUnloaded(file: node_modules/@nativescript/core/ui/core/view/index.android.js:284:0)
System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:300:0)
System.err: at callFunctionWithSuper(file: node_modules/@nativescript/core/ui/core/view-base/index.js:291:0)
System.err: at callUnloaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:300:0)
System.err: at unloadView(file: node_modules/@nativescript/core/ui/core/view-base/index.js:445:0)
System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:228:0)
System.err: at eachChildView(file: node_modules/@nativescript/core/ui/layouts/layout-base-common.js:101:0)
System.err: at eachChild(file: node_modules/@nativescript/core/ui/core/view/view-common.js:700:0)
System.err: at onUnloaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:227:0)
System.err: at onUnloaded(file: node_modules/@nativescript/core/ui/core/view/index.android.js:284:0)
System.err: at (file: node_modules/@nativescript/core/ui/core/view-base/index.js:300:0)
System.err: at callFunctionWithSuper(file: node_modules/@nativescript/core/ui/core/view-base/index.js:291:0)
System.err: at callUnloaded(file: node_modules/@nativescript/core/ui/core/view-base/index.js:300:0)
System.err: at DialogFragmentImpl.onDismiss(file: node_modules/@nativescript/core/ui/core/view/index.android.js:168:0)
System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1302)
System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1188)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1175)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1153)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1149)
System.err: at com.tns.gen.androidx.viewpager.widget.PagerAdapter_vendor_135210_28_FragmentPagerAdapter.destroyItem(PagerAdapter_vendor_135210_28_FragmentPagerAdapter.java:45)
System.err: at androidx.viewpager.widget.ViewPager.dataSetChanged(ViewPager.java:1047)
System.err: at androidx.viewpager.widget.ViewPager$PagerObserver.onChanged(ViewPager.java:3097)
System.err: at androidx.viewpager.widget.PagerAdapter.notifyDataSetChanged(PagerAdapter.java:291)
System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1302)
System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1188)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1175)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1153)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1149)
System.err: at com.tns.gen.androidx.fragment.app.DialogFragment_vendor_115854_28_DialogFragmentImpl.onDismiss(DialogFragment_vendor_115854_28_DialogFragmentImpl.java:25)
System.err: at androidx.fragment.app.DialogFragment$3.onDismiss(DialogFragment.java:120)
System.err: at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1407)
System.err: at android.os.Handler.dispatchMessage(Handler.java:107)
System.err: at android.os.Looper.loop(Looper.java:214)
System.err: at android.app.ActivityThread.main(ActivityThread.java:7356)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
System.err: Caused by: java.lang.IllegalStateException: Cannot detach Fragment attached to a different FragmentManager. Fragment FragmentBase_vendor_135144_28_TabFragmentImplementation{f89a49e} (2f3646ad-0ab5-459a-9c9e-20f4ee91cb19) id=0xd android:viewpager:13:0} is already attached to a FragmentManager.
System.err: at androidx.fragment.app.BackStackRecord.detach(BackStackRecord.java:222)
System.err: ... 25 more
But closing the same dialog using this.params.closeCallback() works.
It seems recent commits related to detaching components has broken something in dialogs.
Metadata
Metadata
Assignees
Labels
No labels
Activity
edusperoni commentedon Sep 21, 2020
Hey @mohammadrafigh
Does this also happen on 10.1.2?
mohammadrafigh commentedon Sep 21, 2020
edusperoni commentedon Sep 21, 2020
Can you provide a sample project?
edusperoni commentedon Sep 21, 2020
@mohammadrafigh I managed to reproduce the issue, but it also happens on 10.1.0 for me.
Are you sure it worked on <10.1.3?
mohammadrafigh commentedon Sep 22, 2020
@edusperoni sorry for delay, I may be wrong at versions since I'm updating NS day to day to see if any of dozens of issues I faced after upgrading to NS7 has been fixed or not. Thanks for putting time on contribution in NS. I hope some day I can improve some aspects too.