When should the cell be updated to display the downloaded image? If you execute self.collectionView?.reloadItems(at: [indexPath]) in completed: у метода sd_setImage , then a loop occurs
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: customCellIdentifier, for: indexPath) as! CustomCell cell.avatarImage.sd_setImage(with: URL(string: user[indexPath.row].avatarURL)!, placeholderImage: UIImage.defaultAvatar()) return cell } The same situation in AlamofireImage