XCode 13 issue - Thread 1: EXC_BAD_ACCESS (code=1, address=0x10)

Good day everyone.

Have problems with xcode 13 (worst update i've ever seen). On xcode 12.5.1 all works fine and run with no issues on real devices iOS 14/15. But on xcode 13.0 i faced strange things.

Runing/building on device/TestFlight and getting crash: Thread 1: EXC_BAD_ACCESS (code=1, address=0x10)

In place where all must be right.

titleLbl.attributedText = nil

All variables are alive and we have access to it in console.

About crash place: It's view in UICollectionViewCell and code called from prepareForReuse in mainThread. Everything must be ok. But... If i comment this line, we'll crash in another place with label and attr string. And etc.

On XC12 all works fine on iOS 14/15. No issues.

Attaching screen and parts of code from trace.

Can anyone help me with this? Please.

Shorted path of call - only main points:

# - 1
 override func layoutSubviews() {
            reload_fromLayout = true
            super.layoutSubviews()
...
}
# - 2
collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath)
....
# - 3
override func prepareForReuse() {
        super.prepareForReuse()
        content.prepareForReuse()
    }
# - 4 - final crash point
func prepareForReuse() {
        storeView.prepareForReuse()
        giftView.prepareForReuse()
        marker_data = nil
    }
# - 5
func prepareForReuse() {
        store_data = nil
        imageView.image = nil
        titleLbl.attributedText = nil
        distanceView.prepareForReuse()
    }
code-block

Answered by show6time in 691516022

Thanks for try to help. Issue resolved. For some reasons content was placed in cell.contentView with some incorrect constraints and contentView had zero size. And this time(xc13) contentView was just terminated in runtime with all view in a some moment while it's on screen. Corrected constraints fixed issue.

What type is titleLbl ? Is it UILabel! ?

Do you get the problem on simulator as well ?

I tested the following in Xcode 13, iOS15 simulator:

     @IBOutlet weak var label        : UILabel! 

in viewDidLoad:

     label.attributedText = nil

No crash.

Could you show the full code, by pasting it, not a partial screen shot.

titleLbl == UILabel

You mean titleLbl is a UILabel ? How is it created ? Where ?

Could you check it is not nil ?

func prepareForReuse() {
        store_data = nil
        imageView.image = nil
        print("titleLbl is", titleLbl)       // <<-- ADD THIS
        titleLbl.attributedText = nil
        distanceView.prepareForReuse()
    }

Label isn't nil. "all variable are alive, views have superviews, windows, etc."

We have complicated UI with some kind of private framework which used in 3 big apps a long time. I'll try show what i can show, but i think it's kind of XC bug. titleLbl - is a part of custom UIView which is placed into UICollectionView.

// Custom view part
private var titleLbl: SF.UI.Elements.Label = {
        let style = SF.UI.Elements.Label.Style.Default.SF__TwoLine
        let view = SF.UI.Elements.Label(style: style)
        view.backgroundColor = .clear
        view.minimumScaleFactor = 0.2
        view.adjustsFontSizeToFitWidth = true
        return view
    }()

init() {
        ...
        configure()
        ...
}

override func configure() {
        super.configure()
        ....
        addSubview(titleLbl)
        ....
}


// cell part
private lazy var storeView: SS_KickGift__StoreView = {
    let style = SF.UI.Elements.View.Style.Default.SF__Base
    let view = SS_KickGift__StoreView(style: style)
    view.clipsToBounds = true
    return view
}()

override func configure() {
        super.configure()
        ...
        addSubview(storeView)
        ...
}

    override init(frame: CGRect) {
            super.init(frame: frame)
            ...
            configure()
            ...
        }

        init(style: SF_UI_Elements_TableCell__Style_Protocol, reuseIdentifier: String?) {
            super.init(frame: .zero)
            ...
            configure()
            ...
        }
code-block
Accepted Answer

Thanks for try to help. Issue resolved. For some reasons content was placed in cell.contentView with some incorrect constraints and contentView had zero size. And this time(xc13) contentView was just terminated in runtime with all view in a some moment while it's on screen. Corrected constraints fixed issue.

I have the same error

Can anyone help me with this? Please.

XCode 13 issue - Thread 1: EXC_BAD_ACCESS (code=1, address=0x10)
 
 
Q