SnapKit: Fatal error: updated constraint could not find existing matching constraint to update
New Issue Checklist
- I have looked at the Documentation
- I have read the F.A.Q.
- I have filled out this issue template.
Issue Info
| Info | Value |
|---|---|
| Platform | ios |
| Platform Version | 12.2 |
| SnapKit Version | 5.0.0 |
| Integration Method | cocoapods |
Issue Description
After SnapKit update (5.0.0 was 4.2.0) I have now fatal error on updateConstraints
Updated constraint could not find existing matching constraint to update
After some investigations I discovered where the issue is located: LayoutConstraint.swift
The object comparison between firstAnchor or secondAnchor doesn’t work properly.
I don’t understand the purpose of #574 because firstItem is unowned(unsafe) meaning it’ll crash if you try to update constraints for deallocated object
The real question is: Why are you trying to update constraints for deallocated objects 😄
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 17 (6 by maintainers)
@sashabelonogov, sure, it fails with margin properties, with
topMarginfor instance, but no crash with.top.Simply use this sample code to test the crash:
encounter same problem
No. We just raised the regression about margins update crash, but no strong investigation started to fix it (simply rollback).
The point of the https://github.com/SnapKit/SnapKit/pull/574 is that the object that the constraints are updated for is not deallocated and the EXC_BAD_ACCESS is raised when the firstItem or secondItem are accessed. The problem is fixed with https://github.com/SnapKit/SnapKit/pull/574. Please, follow Apple documentation about this properties: