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

[Unknown process name] CGAffineTransformInvert: singular matrix #24

Closed
djrobby opened this issue Jul 4, 2020 · 2 comments
Closed

[Unknown process name] CGAffineTransformInvert: singular matrix #24

djrobby opened this issue Jul 4, 2020 · 2 comments

Comments

@djrobby
Copy link

djrobby commented Jul 4, 2020

First off, your utility is AMAZING! Thank you so much for this! I'm running into the following warning/error:

2020-07-04 08:37:50.344351-0400 NavStackTest[11370:1800054] [Unknown process name] CGAffineTransformInvert: singular matrix.
2020-07-04 08:37:50.344494-0400 NavStackTest[11370:1800054] [Unknown process name] CGAffineTransformInvert: singular matrix.
2020-07-04 08:37:50.365485-0400 NavStackTest[11370:1800054] [Unknown process name] CGAffineTransformInvert: singular matrix.
2020-07-04 08:37:50.561570-0400 NavStackTest[11370:1800054] [Unknown process name] CGAffineTransformInvert: singular matrix.
2020-07-04 08:37:52.577640-0400 NavStackTest[11370:1800054] [Unknown process name] CGAffineTransformInvert: singular matrix.
2020-07-04 08:37:52.779411-0400 NavStackTest[11370:1800054] [Unknown process name] CGAffineTransformInvert: singular matrix.
2020-07-04 08:37:52.779592-0400 NavStackTest[11370:1800054] [Unknown process name] CGAffineTransformInvert: singular matrix.

After doing some digging, it seems to be originating from specifying the transitionType attribute for the NavigationStackView while having a List view inside the destination. If I leave this attribute out, there are no errors. Also, I'm not sure if this is related to an already closed issue #22. It would be greatly appreciated if you can help. Thank you in advance. Please see reproducible code see below:

import SwiftUI
import NavigationStack

struct ContentView: View {
  var body: some View {
    NavigationStackView(transitionType: .custom(.scale)) {
      ZStack {
        Color.orange.edgesIgnoringSafeArea(.all)
        HStack {
          PushView(destination:ChildView()) {
            Text("Settings")
          }
        }
      }
    }
  }
}

struct ContentView_Previews: PreviewProvider {
  static var previews: some View {
    ContentView()
  }
}

struct ChildView: View {
  @State var appName: String = ""
  var body: some View {
    ZStack {
      Color.yellow.edgesIgnoringSafeArea(.all)
      
      VStack {
        List {
          ForEach(0...10, id: \.self) { i in
            ListRow(item: "One")
          }
        }
        
        PopView { Text("Go Back") }
      }
    }
  }
}

struct ListRow: View {
  @State var item: String
  var body: some View {
    Text(self.item)
  }
}
@matteopuc
Copy link
Owner

Hi @djrobby! The issue you are experiencing is due to the .scale transition type . Sometimes when you "scale things" in SwiftUI you get these kind of warnings. Don't ask me why, I honestly don't know. If you change your example and try to use, for instance, .slide as transition type the warning will disappear.

struct ContentView: View {
    var body: some View {
        NavigationStackView(transitionType: .custom(.slide)) { //<-- changed here
            ZStack {
                Color.orange.edgesIgnoringSafeArea(.all)
                HStack {
                    PushView(destination:ChildView()) {
                        Text("Settings")
                    }
                }
            }
        }
    }
}

It seems that the warning occurs when you try to set the scale factor to 0 (i.e. the default scale factor for the .scale transition type). To solve this issue you can use a workaround: instead of using .scale as transition type, try to use .scale(0.001):

struct ContentView: View {
    var body: some View {
        NavigationStackView(transitionType: .custom(.scale(scale: 0.001))) { //<-- changed here
            ZStack {
                Color.orange.edgesIgnoringSafeArea(.all)
                HStack {
                    PushView(destination:ChildView()) {
                        Text("Settings")
                    }
                }
            }
        }
    }
}

This way SwiftUI won't scale the view until 0 and the warning will disappear.

@djrobby
Copy link
Author

djrobby commented Jul 7, 2020

You're 100% correct. That did it! Thank you @matteopuc

@djrobby djrobby closed this as completed Jul 7, 2020
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

2 participants