Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewAlertForLayoutOutsideViewHierarchy error: Warning once only (iOS 13 GM)

I am getting a strange error with iOS13 when performing a Segue and I can't figure out what it means, nor can I find any documentation for this error. The problem is that this seems to cause a lot of lag (a few seconds) until the segue is performed.

2019-09-11 22:45:38.861982+0100 Thrive[2324:414597] [TableView] Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window). This may cause bugs by forcing views inside the table view to load and perform layout without accurate information (e.g. table view bounds, trait collection, layout margins, safe area insets, etc), and will also cause unnecessary performance overhead due to extra layout passes. Make a symbolic breakpoint at UITableViewAlertForLayoutOutsideViewHierarchy to catch this in the debugger and see what caused this to occur, so you can avoid this action altogether if possible, or defer it until the table view has been added to a window. Table view: ; layer = ; contentOffset: {0, 0}; contentSize: {315, 118}; adjustedContentInset: {0, 0, 0, 0}; dataSource: >

I am using Hero but I tried disabling it and using a regular Segue and this hasn't stopped the lag.

The code to initiate the segue is didSelectRowAt

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if indexPath.section == 0 {
            selectedCell = realIndexFor(activeGoalAt: indexPath)
            performSegue(withIdentifier: "toGoalDetails", sender: nil)
        } else if indexPath.section == 1 {
            selectedCell = indexPath.row
            performSegue(withIdentifier: "toIdeaDetails", sender: nil)
        } else {
            selectedDecision = indexPath.row
            hero(destination: "DecisionDetails", type: .zoom)
        }
    }

And then none of the code in viewDidLoad or viewWillAppear from the destination VC affects this in any way (I tried commenting it all out with no difference.

Any idea what's causing this? I can share whatever other details are needed.

Thank you.

like image 439
CristianMoisei Avatar asked Sep 11 '19 21:09

CristianMoisei


2 Answers

It happened to me because I registered the device for change orientation notification in the viewWillAppear(:) method. I moved the registration in the viewDidAppear(:) and Xcode it's not stopping at the breakpoint anymore.

What I can say is that layout changes might be run when the view is already visible...

like image 140
Miniapps Avatar answered Nov 07 '22 03:11

Miniapps


For people using DiffableDataSource, set animatingDifferences to false and warning will be gone.

dataSource.apply(snapshot, animatingDifferences: false)

like image 8
Denis Kakačka Avatar answered Nov 07 '22 03:11

Denis Kakačka