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

[iOS 16] App freeze when hitting back on navigation bar, using a WrappingHastack in a view as a NavigationLink #26

Closed
sadaf-behbahani opened this issue Sep 20, 2022 · 4 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@sadaf-behbahani
Copy link

sadaf-behbahani commented Sep 20, 2022

Describe the bug
On iOS 16, app meets a severe hang when using a wrappingHastack inside of a navigation link if you hit back button on the navigation bar.

To Reproduce
Steps to reproduce the behavior:

struct ContentView: View {
    var body: some View {
        NavigationView {
            VStack {
                NavigationLink("Hit me ") {
                    WrappingView()
                }
            }
        }
    }
}


import WrappingHStack

struct WrappingView: View {
    @State private var array: [String] = []
    var body: some View {
        VStack {
            WrappingHStack(array,
                           id: \.self,
                           alignment: .center,
                           spacing: .constant(10)) { topic in
                Text(topic)
            }
        }
        .onAppear {
            array = ["test",
                     "test3",
                     "test4",
                     "test5",
                     "test6",
                     "test7"]
        }
    }
}

  • run the app with code above,
  • hit the navigation link
  • hit back button on the navigation bar

Expected behavior
Go back the previous screen and not freeze the app

Screenshots
If applicable, add screenshots to help explain your problem.
Screenshot 2022-09-20 at 13 04 42

Context:

  • WrappingHStack version: [e.g. 2.2.1]
  • Model: iPhone 13 pro, simulator , iPhone 11
  • OS: iOS 16

Additional context
Freeze happens only if you use this lib inside of a Navigation link

@sadaf-behbahani sadaf-behbahani added bug Something isn't working help wanted Extra attention is needed labels Sep 20, 2022
@dkk
Copy link
Owner

dkk commented Sep 23, 2022

It seems to be related to an issue when using NavigationLink with contained GeometryReaders that are not inside a NavigationView. The workaround is to set a NavigationView around the WrappingHStack.

In your example, you could use:

struct ContentView: View {
    var body: some View {
        NavigationView {
            VStack {
                NavigationLink("Hit me ") {
                    WrappingView()
                }
            }
        }
    }
}


import WrappingHStack

struct WrappingView: View {
    @State private var array: [String] = []
    var body: some View {
       NavigationView { // <<<< HERE
            VStack {
                WrappingHStack(array,
                               id: \.self,
                               alignment: .center,
                               spacing: .constant(10)) { topic in
                    Text(topic)
                }
            }
            .onAppear {
                array = ["test",
                     "test3",
                     "test4",
                     "test5",
                     "test6",
                     "test7"]
            }
        }
    }
}

For more information see this link

@dkk dkk closed this as completed Sep 23, 2022
@dkk
Copy link
Owner

dkk commented Sep 23, 2022

I have added this use case to the example app

@sadaf-behbahani
Copy link
Author

Thank you 🙏

@andriy-appuchino
Copy link

@dkk I have a similar problem in two cases but a more complicated structure. The workaround doesn't help.

Case 1

TabView {
    NavigationView {
        ScrollView {
            WrappingHStack {

Case 2

TabView {
    NavigationView {
        ScrollView {
            NavigationLink {
                ScrollView {
                    WrappingHStack {

There are also intermediate views and ZStacks and VStacks that I didn't mention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants