What is NSISEngine?

I am browsing my application and I noticed that when I load certain (4 out of 112 to be exact) objects and load it in ViewControllerwith 4 UIStackView, everything written with code (i.e. no xib) there is a noticeable lag when loading, and especially when loading UIStackViews. I ran a performance trace and noticed the only difference between the quickly viewed views, and those that lag behind are methods NSISEnginethat call more than 6 times (especially [NSISEngine Optimize]). Does anyone know why this only pops up for <5% of cases?

  • The amount of data for each object does not matter, since there are large objects that do not have this problem.
  • I use custom ones UIStackViewthat expand when used, and this is the code I use:

     func toggle() {
        // only toggle if there a subView
        guard subView != nil else {
            return
        }
        let rotation = isExpanded ? 0 : π / 2
        isExpanded = !isExpanded
        setSpacing(for: self) // this takes 1e-6s 
        t1 = Date()
        UIView.animate(withDuration: kExpansionTime, animations: {
            self.arrowView.transform = CGAffineTransform(rotationAngle: rotation)
            self.subView?.isHidden = !self.isExpanded
            self.layoutIfNeeded() // no change if this is removed.
        }) {_ in
            t2 = Date()
            print(t2.timeIntervalSince(t1)) // prints ~1s on bad cases and 1e-3 normally
        }
    }  
    

Change . This does not happen on iOS 10, only on iOS 9 (maybe this is a bug)?

+4
source share
1 answer

If someone was interested to know what causes the optimization problem, I used UILabelc numberOfLines = 0. Labelwas in StackViewwhich had the following properties

stackView.axis = .vertical
stackView.alignment = .center
stackView.distribution = .fillProportionally

I switched numberOfLines = 1and he fixed it.

0
source

Source: https://habr.com/ru/post/1664067/


All Articles