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 #14

Closed
gloparco opened this issue Oct 19, 2015 · 10 comments
Closed

NSRangeException #14

gloparco opened this issue Oct 19, 2015 · 10 comments

Comments

@gloparco
Copy link

Hi Johannes, thanks for ActiveLabel - nice work!

I notice that when using ActiveLabel in a CollectionView and scrolling up or down, I sometimes get the following error:

*** Terminating app due to uncaught exception 'NSRangeException', reason: 'NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds'

This has also been documented in another UILabel github lib (Obj-C), here:

SebastianThiebaud/STTweetLabel#55

The bug is hard to reproduce, but it has happened multiple times. It doesn't appear to be associated with the speed of scrolling or anything else I can reproduce, but as I mentioned, it has happened multiple times now, and it does seem related to ActiveLabel. Sorry I can't be of more help.

@gloparco
Copy link
Author

Just to add to it, here is a long discussion on the topic (from a site that I had never heard of before):

http://youranswers.info/question/view/en/YUhSMGNEb3ZMM04wWVdOcmIzWmxjbVpzYjNjdVkyOXRMM0YxWlhOMGFXOXVjeTh4T0RrMk1qYzBNaTkxYVhSbGVIUjJhV1YzTFd4cGJtc3RaR1YwWldOMGFXOXVMV2x1TFdsdmN5MDM=

I'm not sure if this can be prevented by your code, but it might be worth looking into. It seems to have something to do with AttributedString, but it does not appear to be certain.

@schickling
Copy link
Contributor

Hi @gloparco! Thanks for reporting this.
We're using ActiveLabel just as part of a UITableView, so we haven't had this issue so far and unfortunately don't have the capacity at the moment to look into it in depth.

However we'd be more than happy to merge a PR which resolves this issue.

@ammerzon
Copy link

ammerzon commented Feb 3, 2016

@gloparco I am using ActiveLabel in an UITableViewCell but every time i set a text containing an @ or # I get a NSRangeException.

@polqf polqf mentioned this issue Feb 4, 2016
9 tasks
@polqf
Copy link
Contributor

polqf commented Feb 4, 2016

Hi @byAmmerix, in what SDK and iOS version have you noticed it?

@ammerzon
Copy link

ammerzon commented Feb 5, 2016

I am using:
Cocoapods: pod 'ActiveLabel', '~> 0.4'
iOS version/SDK: 9.2

It is the same bug as @JaviSoto already mentioned in #40.
The crash occurs at:
mutAttrString.setAttributes(attributes, range: element.range)

@alexbredy
Copy link

+1 happens to me every time i close and reopen a given tableview repeatedly.

@polqf
Copy link
Contributor

polqf commented Feb 12, 2016

@alexbredy what dependency manager are you using? iOS and SDK version?

@alexbredy
Copy link

Hi @poolqf

Using Cocoapods with
iOS version 9.2.1 and SDK 9.2 (Xcode 7.2.1)

Update regarding the issue I'm having:
The crash does not occur if I'm not adding cells upon opening the tableview. Somehow when I keep adding rows with the same url it crashes after 4-5 times closing and reopening the tableview.

The crash does not happen if the cells are unaltered.

@adergaard
Copy link

The problem is most likely possibly due to row 190 in ActiveLabel.swift:

dispatch_async

Quickfix: Comment out that row (and consequently the closing } on row 194) and let the commands execute on the main thread instead and the crash is no more.

Be very careful trying to do stuff outside the main thread.
It's therefore also well worth noting the dispatch_after call made in the onTouch method.

@polqf
Copy link
Contributor

polqf commented Feb 17, 2016

I've removed the dispatch_async in #47
I am now going to create a new release. Closing this issue.

Feel free to reopen it if it happens again

cc/ @byAmmerix , @alexbredy , @JaviSoto

@polqf polqf closed this as completed Feb 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants