nativescript-community / ui-material-components

Monorepo that contains all of the NativeScript Material Design plugins.
https://nativescript-community.github.io/ui-material-components/
Apache License 2.0
219 stars 80 forks source link

BottomSheet: Crash on Android when using Frame in BottomSheet #234

Open felixkrautschuk opened 3 years ago

felixkrautschuk commented 3 years ago

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.

When using a Frame inside a BottomSheet, the app crashes while trying to open that BottomSheet on Android.

<!-- bottomsheet -->
<GridLayout rows="*" iosIgnoreSafeArea="true" height="500">
    <Frame id="frameMenu" defaultPage="menu-page" actionBarVisibility="never"/>
</GridLayout>
<!-- menu-page -->
<Page actionBarHidden="true">
    <StackLayout>
        <Button text="Button 1" id="1" tap="onButtonTap"/>
        <Button text="Button 2" id="2" tap="onButtonTap"/>
        <Button text="Button 3" id="3" tap="onButtonTap"/>
        <Button text="Button 4" id="4" tap="onButtonTap"/>
    </StackLayout>
</Page>

Crash log:

System.err: An uncaught Exception occurred on "main" thread. System.err: No view found for id 0x2 (unknown) for fragment fragment1[1]Page(8)@menu-page.xml:1:1; System.err: System.err: StackTrace: System.err: java.lang.IllegalArgumentException: No view found for id 0x2 (unknown) for fragment fragment1[1]Page(8)@menu-page.xml:1:1; System.err: at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:315) System.err: at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1199) System.err: at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1368) System.err: at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1446) System.err: at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1509) System.err: at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:447) System.err: at androidx.fragment.app.FragmentManager.executeOps(FragmentManager.java:2181) System.err: at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2004) System.err: at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1959) System.err: at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1861) System.err: at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:413) System.err: at android.os.Handler.handleCallback(Handler.java:883) System.err: at android.os.Handler.dispatchMessage(Handler.java:100) 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)

While researching I came across this issue: https://github.com/NativeScript/NativeScript/issues/8126 It's about the same error message so it is possible that this issue here is not caused by the bottom-sheet alone. However, the other issue is about suspending and resuming the app which is not the case here, so it might have a different cause.

Which platform(s) does your issue occur on?

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

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

Open the sample app provided above, tap the button to open the bottom sheet -> Crash (Anroid)

Is there any code involved?

NSBottomSheetNS7.zip

vallemar commented 3 years ago

+1

farfromrefug commented 3 years ago

@felixkrautschuk still happening?

felixkrautschuk commented 3 years ago

@farfromrefug I updated all dependencies (nativescript/core 7.3.0, nativescript/android 7.0.1 and the bottomsheet plugin 5.2.31) and yes, it is still happening the same way.

Updated project: NSBottomSheetNS7.zip

I also tried updating NS 8 in combination with the bottomsheet 5.2.31, but no difference.

farfromrefug commented 3 years ago

@felixkrautschuk it seems to be an issue with N. Something is really wrong with the way N handles fragment managers. It creates a lot of issues all over the place. I cant do much right now as it would requires a lot of time/work to correctly fix this. For now i would suggest not to use a frame inside a bottomsheet. Which btw is not a good ui design. There should be no navigation inside a bottomsheet

felixkrautschuk commented 3 years ago

@farfromrefug thanks for your feedback.

I have already thought of something like that, because I firstly came across this kind of crash in an app without using the bottomsheet. But the sample app containing the bottomsheet was the only app where I could reproduce this crash so I decided to create the issue thread here instead of the core repo :)

farfromrefug commented 3 years ago

@felixkrautschuk yes i understand. Maybe it would be a good thing then to raise ald link this issue in the N one? We now have a reproducible example

farfromrefug commented 1 year ago

@felixkrautschuk i am now thinking it is a bug on the plugin side. The reason is that in N it works for modal views which work the same way as the bottomsheet on android