Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
felixkrautschuk opened this issue Feb 3, 2021 · 7 comments
Open

Comments

@felixkrautschuk
Copy link

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: NativeScript/NativeScript#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?

  • Android
  • tested on 6, 9, 10, 11
  • emulator and device

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

  • CLI: 7.1.2
  • Cross-platform modules: @nativescript/core 7.1.4
  • Runtime(s): @nativescript/android 7.0.1 and @nativescript/ios 7.1.1
  • Plugin(s): @nativescript-community/ui-material-bottomsheet 5.2.3

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
Copy link
Contributor

vallemar commented Apr 2, 2021

+1

@farfromrefug
Copy link
Member

@felixkrautschuk still happening?

@felixkrautschuk
Copy link
Author

@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
Copy link
Member

@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
Copy link
Author

@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
Copy link
Member

@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
Copy link
Member

@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

@farfromrefug farfromrefug reopened this Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants