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

NSRangeException: *** -[NSMutableIndexSet addIndexesInRange:]: Range {18446744073709551614, 1} exceeds maximum inde... #21085

Closed
sentry-io bot opened this issue Jul 12, 2023 · 3 comments

Comments

@sentry-io
Copy link

sentry-io bot commented Jul 12, 2023

Sentry Issue: JETPACK-IOS-G84

NSRangeException: *** -[NSMutableIndexSet addIndexesInRange:]: Range {18446744073709551614, 1} exceeds maximum index value of NSNotFound - 1
  File "WPPHAssetDataSource.m", line 375, in -[WPPHAssetDataSource adjustedIndexesForIndexSet:forCount:]
  File "WPPHAssetDataSource.m", line 369, in -[WPPHAssetDataSource adjustedIndexesForIndexSet:]
  File "WPPHAssetDataSource.m", line 101, in __45-[WPPHAssetDataSource photoLibraryDidChange:]_block_invoke
  File "main.swift", line 7, in main
...
(15 additional frame(s) were not displayed)
@kean
Copy link
Contributor

kean commented Jul 26, 2023

I tried removing/adding photos while the device media picker is open, but couldn't get it to crash. I also tested a scenario when the device is empty.

Message:

NSRangeException: *** -[NSMutableIndexSet addIndexesInRange:]: Range {18446744073709551534, 1} exceeds maximum index value of NSNotFound - 1`

The likely explanation is that there is something wrong with this method or the way it is called:

- (NSInteger)adjustedIndexForIndex:(NSInteger)index forCount:(NSInteger)count
{
    if (self.ascendingOrdering) {
        return index;
    }

    // Adjust the index so items are returned in reverse order.
    // We do this, rather than specifying the sort order in PHFetchOptions,
    // to preserve the sort order of assets in the Photos app (only in reverse).
    return (count - 1) - index;
}

The value 18446744073709551534 may be the result of converting a negative value, such as -1, from NSInteger to NSUInteger that NSIndexSet works with.


I'm assigning a low priority because it happens extremely rarely.

The best solution would be to replace the custom picker with a native picker that supports search, filtering by favorites, and many other features.

@kean
Copy link
Contributor

kean commented Aug 16, 2023

This will be fixed in the scope of #21190

@kean
Copy link
Contributor

kean commented Nov 10, 2023

As expected – no occurrences since the 23.2 release. Closing.

@kean kean closed this as completed Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants