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: Aztec.TextStorage attributedSubstringFromRange:: Out of bounds #12626

Open
sentry-io bot opened this issue Oct 4, 2019 · 19 comments
Open

Comments

@sentry-io
Copy link

sentry-io bot commented Oct 4, 2019

Sentry Issue: WORDPRESS-IOS-1W6P

NSRangeException: NSMutableRLEArray replaceObjectsInRange:withObject:length:: Out of bounds
  ?, in <redacted>
...
(34 additional frame(s) were not displayed)

This one seems like it could be due to the device just not having enough memory🤔

@designsimply
Copy link
Contributor

designsimply commented Oct 7, 2019

7-day impact: 29 (new crash)
Users affected in the last 7 days: 22
First seen in: 13.2.3.1

https://sentry.io/share/issue/94e42b8dcb934785a6c2d37238fcb1d2/

@designsimply
Copy link
Contributor

22-day impact: ~7 per day
Users affected in the last 22 days: 86
First seen in: 13.2.3.1

https://sentry.io/share/issue/94e42b8dcb934785a6c2d37238fcb1d2/

@designsimply
Copy link
Contributor

@koke is it reasonable to assume this one is due to not having enough memory free on the device? I looked through several of the crashes and many had <100MB free and some had as much as 290MB free.

@koke
Copy link
Member

koke commented Oct 23, 2019

I don't think it's related to memory. Looking at the crash I see:

  • This seems to happen in WordPress.AztecPostViewController
  • There is UITextDragAssistant in the stack trace, and other class names that seem to point to this happening when using drag and drop on text
  • This was first encountered in 13.2.3.1

The only change in 13.2.3.1 that seems relevant is #12548 (cc @SergioEstevao)

I've been messing around selecting things and trying to drag text around in the editor but I haven't been able to reproduce.

However that code in #12548 is modifying the current selection in the text view. So it might be that memory pressure has something to do with it. In my testing, if I try to drag and drop a link when the editor doesn't have the focus, the code that brings the focus runs before the link appears draggable, but if the device is being slow, I could imagine the dragging UI appearing first, and while the user is dragging the link the shouldInteractWithURL method would get called and change the selection causing the crash.

@SergioEstevao I don't fully understand the implementation in #12548. If I implement the delegate method but just return false it seems to behave as expected, and it would be less likely to interfere with other moving parts in UIKit. Any reasons not to do that?

@SergioEstevao
Copy link
Contributor

SergioEstevao commented Oct 23, 2019

@SergioEstevao I don't fully understand the implementation in #12548. If I implement the delegate method but just return false it seems to behave as expected, and it would be less likely to interfere with other moving parts in UIKit. Any reasons not to do that?

That works for version for iOS 13.1 and above but not on 13.0

I can add a platform check just to make sure we only run it on 13.0, like we did for Gutenberg mobile:

func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
        if #available(iOS 13.1, *) {
            return false
        } else if #available(iOS 13.0.0, *) {
            // Sergio Estevao: This shouldn't happen in an editable textView, but it looks we have a system bug in iOS13 so we need this workaround
            let position = characterRange.location
            textView.selectedRange = NSRange(location: position, length: 0)
            textView.typingAttributes = textView.attributedText.attributes(at: position, effectiveRange: nil)
            textView.delegate?.textViewDidChangeSelection?(textView)
        } else {
            return false
        }

        return false
    }```

@koke
Copy link
Member

koke commented Oct 23, 2019

Gotcha, I remember 13.0 was related somehow, but I missed the connection. Currently 13.0 usage is around 1% and dropping. I think I would be ok with the buggy behavior on 13.0 if it gets us out of the crash

@sentry-io
Copy link
Author

sentry-io bot commented Mar 27, 2020

Sentry Issue: WORDPRESS-IOS-5QA

NSRangeException: NSMutableRLEArray replaceObjectsInRange:withObject:length:: Out of bounds
  File "main.swift", line 7, in main
...
(34 additional frame(s) were not displayed)

Events in the last 90 days: 2,900
Users affected in the last 90 days: 369

@designsimply
Copy link
Contributor

designsimply commented Mar 27, 2020

I searched Sentry for "NSMutableRLEArray replaceObjectsInRange:withObject:length:: Out of bounds" and found no crashes recorded for that error in 14.3.0.3 on iOS 13.3. No crashes for iOS 13.0 or 13.1 either.

Note that there are still crashes happening for the same error on 14.3.0.3 on iOS 13.3.1 though.

@designsimply
Copy link
Contributor

Sentry Issue: WORDPRESS-IOS-5QA
Events in 14.3.0.3 since it was released 18d ago on Mar 9: 80

@designsimply
Copy link
Contributor

Events in the last 90d: 3,500
Events in the last 11d for 14.9: 34 in 14.9 since it was released on 2020-06-01
Users affected in the last 90d: 380
https://sentry.io/share/issue/f975828a305e4efb9e2ad4ac9d6e273d/

@designsimply
Copy link
Contributor

Events in the last 90d: 4,000
Users affected in the last 90d: 351
Events in the latest release: 16 (15.3 released 13d ago on 2020-07-24)
https://sentry.io/share/issue/f975828a305e4efb9e2ad4ac9d6e273d/

Note: seems to be happening less and less often in the latest releases.

image

@designsimply
Copy link
Contributor

Events in the last 90d: 642
Users affected in the last 90d: 319
WORDPRESS-IOS-5QA: https://sentry.io/share/issue/f975828a305e4efb9e2ad4ac9d6e273d/

image

@designsimply
Copy link
Contributor

Events in the last 90d: 522
Users affected in the last 90d: 267
WORDPRESS-IOS-5QA: https://sentry.io/share/issue/f975828a305e4efb9e2ad4ac9d6e273d/

image

@designsimply
Copy link
Contributor

Events in the last 90d: 4,400
Users affected in the last 90d: 157
WORDPRESS-IOS-5QA: https://sentry.io/share/issue/f975828a305e4efb9e2ad4ac9d6e273d/

image

40% reduction in users affected compared to the last time we checked, and this issue has been open for over 14 months and it's labeled as low priority. @jkmassel is it okay to close this issue?

@guarani
Copy link
Contributor

guarani commented Apr 8, 2024

Noting that this might affect block editor users despite Aztec being in the name.
Logs show that the block editor was opened prior to the crash:

🔵 Tracked: editor_session_start <blog_id: xyz, blog_type: wpcom, content_type: gutenberg, editor: gutenberg, entry_point: postsList, has_unsupported_blocks: 0, post_type: post, session_id: xyz, startup_time_ms: 175, unstable_gallery_with_image_blocks: true, unsupported_blocks: []>

Started a thread on Slack: p1712607058564289-slack-C012H19SZQ8

@twstokes
Copy link
Contributor

twstokes commented Apr 9, 2024

I can confirm that this is also occurring in the block editor @guarani (it uses Aztec components). One commonality I'm seeing with the crashes is Arabic encodings in the content.

@staskus staskus added the Aztec label Apr 9, 2024
@dangermattic
Copy link
Collaborator

Thanks for reporting! 👍

Copy link
Author

sentry-io bot commented Apr 9, 2024

Sentry Issue: WORDPRESS-IOS-5QA

Copy link
Author

sentry-io bot commented Apr 9, 2024

Sentry Issue: JETPACK-IOS-BN

@staskus staskus changed the title NSRangeException: NSMutableRLEArray replaceObjectsInRange:withObject:length:: Out of bounds NSRangeException: Aztec.TextStorage attributedSubstringFromRange:: Out of bounds Apr 9, 2024
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

7 participants