Post

Replies

Boosts

Views

Activity

Reply to Applying new snapshot to diffable data source in iOS 15 trigger unnecessary cell registration call
The definition of ITEM list below, could you see  any problem here? @J0hn class AlbumItem: Hashable {   let albumURL: URL   let albumTitle: String   let imageItems: [AlbumDetailItem]   init(albumURL: URL, imageItems: [AlbumDetailItem] = []) {     self.albumURL = albumURL     self.albumTitle = albumURL.lastPathComponent.displayNicely     self.imageItems = imageItems   }   func hash(into hasher: inout Hasher) {     hasher.combine(identifier)   }   static func == (lhs: AlbumItem, rhs: AlbumItem) -> Bool {     return lhs.identifier == rhs.identifier   }   private let identifier = UUID() } BTW, those unnecessary calling  occurs in  demo on session 10252,to reproduce this issue: add delegate for the collection view, disable prefetching to reduce logs:   private func configureHierarchy() {         collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: createLayout())         collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight]         collectionView.backgroundColor = .systemBackground //        collectionView.prefetchDataSource = self         collectionView.isPrefetchingEnabled = false         collectionView.delegate = self         view.addSubview(collectionView)     } 2.  implement the selection callback for removing item from snapshot: extension PostGridViewController: UICollectionViewDelegate {     func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {         print("remove items at section:(\(indexPath.section)), item:(\(indexPath.item))")         var snapshot = dataSource.snapshot()         let identfiers = snapshot.itemIdentifiers(inSection: Section.ID.allCases[indexPath.section])         snapshot.deleteItems([identfiers[indexPath.item]])         dataSource.apply(snapshot, animatingDifferences: false)     } } finally, remove reload stuff in cell registeration:  let cellRegistration = UICollectionView.CellRegistration<DestinationPostCell, DestinationPost.ID> { [weak self] cell, indexPath, postID in             guard let self = self else { return }             print("configure DestinationPostCell:(\(Unmanaged.passUnretained(cell).toOpaque())) at section:(\(indexPath.section)), item:(\(indexPath.item))")             let post = self.postsStore.fetchByID(postID)             let asset = self.assetsStore.fetchByID(post.assetID)             cell.configureFor(post, using: asset)         } THEN I ran this demo and clicked the first item to remove it, similar log came out: configure DestinationPostCell:(0x000000015ef11940) at section:(0), item:(0) configure DestinationPostCell:(0x000000015ed20410) at section:(0), item:(1) configure DestinationPostCell:(0x000000015ed21900) at section:(1), item:(0) remove items at section:(0), item:(0) configure DestinationPostCell:(0x000000015ed433c0) at section:(1), item:(2) configure DestinationPostCell:(0x000000015ed433c0) at section:(0), item:(0) configure DestinationPostCell:(0x000000015ed433c0) at section:(1), item:(0) configure DestinationPostCell:(0x000000015ed433c0) at section:(1), item:(1) configure DestinationPostCell:(0x000000015ef11940) at section:(1), item:(1)
Jun ’21
Reply to NSURLSessionWebSocketTask return bad address error
Hi @eskimo , thanks for replying and yes, it's really a challenge for us. ============================================ We have had a short touch with this user. He/she is facing a problem where he/she can't receive a specific kind of message for many days. However, he/she has said that the problem has been resolved after uninstalling and reinstalling our app. This means that this issue is highly relevant to our app's data environment. ============================================ My colleague from the server side has informed me that the user's websocket behavior is weird. It connects to our server, sends a normal message(deciding whether the client needs APNs or not), and immediately disconnects. A typical log(from another user also encountering bad address error) looks like this below: [2023-05-26 20:53:42:872][Call webSocketTaskWithRequest:] Create Task: LocalWebSocketTask <XYZ>.<1> withRequest: <NSMutableURLRequest: 0x2807d0480> { URL: A_WS_URL} [2023-05-26 20:53:42:872][Call receiveMessageWithCompletionHandler:] check&reconnect: create a new socket and resume, listen [2023-05-26 20:53:43:083][Callback from URLSession:webSocketTask:didOpenWithProtocol:] Task: LocalWebSocketTask <XYZ>.<1>, didOpenWithProtocol (null) [2023-05-26 20:53:43:083][Call bussinues code ]send push: needPush = 0, message = {"xx":"yy","zz":{"foo":"bar"}} [2023-05-26 20:53:43:083][Call sendPingWithPongReceiveHandler] send ping [2023-05-26 20:53:43:129][Callback from sendPingWithPongReceiveHandler:] receive pong success [2023-05-26 20:53:43:154][Callback from receiveMessageWithCompletionHandler: ]handlerWebSocketTaskError: domain = kNWErrorDomainPOSIX, code = 14 [2023-05-26 20:53:43:154][Call cancel task since we encounter error, ]close&destory LocalWebSocketTask <XYZ>.<1> [2023-05-26 20:53:43:154][Call bussinues code, try to reconnect later]start reconnect(timer: 0x282b9c180) [2023-05-26 20:53:43:154][Callback from URLSession:webSocketTask:didCompleteWithError:] didComplete Task: LocalWebSocketTask <XYZ>.<1> [2023-05-26 20:53:43:154]Callback from URLSession:webSocketTask:didCompleteWithError:] didComplete Error: Error Domain=kNWErrorDomainPOSIX Code=14 "Bad address" UserInfo={NSDescription=Bad address, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalWebSocketTask <XYZ>.<1>" ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalWebSocketTask <XYZ>.<1>} ============================================ We have received further information about this issue after viewing more than 25k error reports: Most of the errors are related to network circumstances, like timeouts, which is understandable. 0.3% of devices are reporting a "bad address" error from "receiveMessageWithCompletionHandler:" and "sendMessage:completionHandler:". 95% of the devices reporting a "bad address" are equipped with iOS 13.x. ============================================ We are planning to use the old websocket implementation on iOS 13 instead of NSURLSessionWebSocketTask if we could not address this issue. :p Thansk for paying attention to this issue :)
May ’23