Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-8745] indexPathForItem(at point: CGPoint) terminating due to internal misuse of -[__NSArrayM insertObject:atIndex:] #51254

Closed
swift-ci opened this issue Sep 14, 2018 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-8745
Radar None
Original Reporter twof (JIRA User)
Type Bug
Status Resolved
Resolution Invalid
Environment

Stable XCode and Swift

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee None
Priority Medium

md5: 2a81948ba8c55df88834cbeae92e0e60

Issue Description:

I'm not sure if this is the correct place to be reporting bugs with UIKit, but let me know if I should move it elsewhere.

This bug triggers 100% of the time with my codebase in its current state, but it was working fine previously. I'm not going to be able to share the full project because it's proprietary, and I doubt I'll be able to create a simple repro, but I'm using this library:
https://github.com/mmick66/KDDragAndDropCollectionView

and the problem line is 62 of KDDragAndDropCollectionView.swift

In case you don't want to go looking through it:

// MARK : KDDraggable
public func canDragAtPoint(_ point : CGPoint) -> Bool {
    if let dataSource = self.dataSource as? KDDragAndDropCollectionViewDataSource,
    let indexPathOfPoint = self.indexPathForItem(at: point) { // Errors out on this one
        return dataSource.collectionView(self, cellIsDraggableAtIndexPath: indexPathOfPoint)
    }

    return false
}

But even if you execute

self.indexPathForItem(at: point)

on its own within that method you hit the same error.

The issue is also not the point. For example, if I hard code (0, 0) and pass that instead, I get the same error.

Console output:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001146a21e6 __exceptionPreprocess + 294
    1   libobjc.A.dylib                     0x0000000113188031 objc_exception_throw + 48
    2   CoreFoundation                      0x00000001146e20bc _CFThrowFormattedException + 194
    3   CoreFoundation                      0x00000001145d12a9 -[__NSArrayM insertObject:atIndex:] + 1273
    4   UIKit                               0x000000011113f7c9 -[UICollectionViewFlowLayout layoutAttributesForElementsInRect:] + 473
    5   UIKit                               0x0000000111169b3b __45-[UICollectionViewData validateLayoutInRect:]_block_invoke + 237
    6   UIKit                               0x0000000111168e60 -[UICollectionViewData validateLayoutInRect:] + 1343
    7   UIKit                               0x000000011116be80 -[UICollectionViewData layoutAttributesForElementsInRect:] + 348
    8   UIKit                               0x0000000111104b80 -[UICollectionView _indexPathForItemAtPoint:] + 213
    9   UIKit                               0x0000000111104a32 -[UICollectionView indexPathForItemAtPoint:] + 23
    10  KDDragAndDropCollectionViews        0x000000010e5858fc _T028KDDragAndDropCollectionViews0abcD4ViewC14canDragAtPointSbSC7CGPointVF + 140
    11  KDDragAndDropCollectionViews        0x000000010e58d2e5 _T028KDDragAndDropCollectionViews0abcD4ViewCAA11KDDraggableA2aDP14canDragAtPointSbSC7CGPointVFTW + 37
    12  KDDragAndDropCollectionViews        0x000000010e58fb3e _T028KDDragAndDropCollectionViews0abC7ManagerC17gestureRecognizerSbSo09UIGestureH0C_So7UITouchC13shouldReceivetF + 878
    13  KDDragAndDropCollectionViews        0x000000010e590871 _T028KDDragAndDropCollectionViews0abC7ManagerC17gestureRecognizerSbSo09UIGestureH0C_So7UITouchC13shouldReceivetFTo + 81
    14  UIKit                               0x0000000110c2f899 -[UIGestureRecognizer _delegateShouldReceiveTouch:] + 129
    15  UIKit                               0x0000000110c2f793 -[UIGestureRecognizer _shouldReceiveTouch:recognizerView:touchView:] + 716
    16  UIKit                               0x0000000111226e69 __56-[UITouchesEvent _addGestureRecognizersForView:toTouch:]_block_invoke + 333
    17  UIKit                               0x0000000111226a2a _UIEventEnumerateGesturesForView + 467
    18  UIKit                               0x0000000111226cec -[UITouchesEvent _addGestureRecognizersForView:toTouch:] + 131
    19  UIKit                               0x000000011122747c -[UITouchesEvent _addTouch:forDelayedDelivery:] + 1333
    20  UIKit                               0x0000000110f8ad64 _AddTouchToEventAndDetermineIfNeedsCancel + 197
    21  UIKit                               0x0000000110f8ade2 ____updateTouchesWithDigitizerEventAndDetermineIfShouldSend_block_invoke.107 + 61
    22  CoreFoundation                      0x0000000114761c5f ____NSDictionaryEnumerate_block_invoke.13 + 31
    23  CoreFoundation                      0x00000001145e7450 CFBasicHashApply + 128
    24  CoreFoundation                      0x000000011462621f __NSDictionaryEnumerate + 207
    25  UIKit                               0x0000000110f8735d __updateTouchesWithDigitizerEventAndDetermineIfShouldSend + 1455
    26  UIKit                               0x0000000110f8bf75 __dispatchPreprocessedEventFromEventQueue + 946
    27  UIKit                               0x0000000110f8f2c4 __handleEventQueueInternal + 5949
    28  CoreFoundation                      0x0000000114644bb1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    29  CoreFoundation                      0x00000001146294af __CFRunLoopDoSources0 + 271
    30  CoreFoundation                      0x0000000114628a6f __CFRunLoopRun + 1263
    31  CoreFoundation                      0x000000011462830b CFRunLoopRunSpecific + 635
    32  GraphicsServices                    0x00000001176b5a73 GSEventRunModal + 62
    33  UIKit                               0x0000000110630057 UIApplicationMain + 159
    34  Redbooth                            0x00000001095298f7 main + 55
    35  libdyld.dylib                       0x0000000115c7a955 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Googled around and couldn't find anyone with similar problems with {code:swift}indexPathForItem(at🙂

@belkadan
Copy link
Contributor

Yeah, sorry, bugs with UIKit should still go to https://bugreport.apple.com, since they're not something we can fix in the Swift Open Source project.

@swift-ci
Copy link
Collaborator Author

Comment by Alex Reilly (JIRA)

Sorry about that. Thanks!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

2 participants