Charts icon indicating copy to clipboard operation
Charts copied to clipboard

NSRangeException - index (1) beyond bounds (1)

Open fgroeger opened this issue 5 years ago • 5 comments

What did you do?

Crash appeared in our crash reporting. We're using a LineChartView with a single dataset (in the case of the crash) with up to ~ 60 entries.

OS Version: iOS 13.3 (17C54)
Report Version: 104

Exception Type: EXC_CRASH (SIGABRT)
Crashed Thread: 0

Application Specific Information:
-[UIPinchGestureRecognizer locationOfTouch:inView:]: index (1) beyond bounds (1).

Thread 0 Crashed:
0   CoreFoundation                  0x34bf2fa48         __exceptionPreprocess
1   libobjc.A.dylib                 0x341a7dfa0         objc_exception_throw
2   CoreFoundation                  0x34be251bc         +[NSException raise:format:]
3   UIKitCore                       0x345892e7c         -[UIGestureRecognizer locationOfTouch:inView:]
4   Charts                          0x28abf8630         [inlined] UIPinchGestureRecognizer.nsuiLocationOfTouch (Platform+Gestures.swift:84)
5   Charts                          0x28abf8630         BarLineChartViewBase.pinchGestureRecognized (BarLineChartViewBase.swift:611)
6   Charts                          0x28ac0a5c0         BarLineChartViewBase.pinchGestureRecognized
7   UIKitCore                       0x34588962c         -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:]
8   UIKitCore                       0x345891d0c         _UIGestureRecognizerSendTargetActions
9   UIKitCore                       0x34588f4a0         _UIGestureRecognizerSendActions
10  UIKitCore                       0x34588ea00         -[UIGestureRecognizer _updateGestureForActiveEvents]
11  UIKitCore                       0x345882994         _UIGestureEnvironmentUpdate
12  UIKitCore                       0x34588210c         -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:]
13  UIKitCore                       0x345881ed0         -[UIGestureEnvironment _updateForEvent:window:]
14  UIKitCore                       0x345cd76f4         -[UIWindow sendEvent:]
15  UIKitCore                       0x345cb3e28         -[UIApplication sendEvent:]
16  UIKitCore                       0x345d2bfa0         __dispatchPreprocessedEventFromEventQueue
17  UIKitCore                       0x345d2e4fc         __handleEventQueueInternal
18  UIKitCore                       0x345d27370         __handleHIDEventFetcherDrain
19  CoreFoundation                  0x34bead9fc         __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
20  CoreFoundation                  0x34bead954         __CFRunLoopDoSource0
21  CoreFoundation                  0x34bead0ec         __CFRunLoopDoSources0
22  CoreFoundation                  0x34bea8238         __CFRunLoopRun
23  CoreFoundation                  0x34bea7ad8         CFRunLoopRunSpecific
24  GraphicsServices                0x34bc43324         GSEventRunModal
25  UIKitCore                       0x345c9badc         UIApplicationMain
26  AppName                         0x200d60d94         main (AppDelegate.swift:16)
27  libdyld.dylib                   0x350b2935c         start

What did you expect to happen?

It should not crash.

What happened instead?

It crashes.

Charts Environment

Charts version/Branch/Commit Number: 3.5 Xcode version: 11.4.1 Swift version: 5.2 Platform(s) running Charts: iOS

Demo Project

None available 😞

fgroeger avatar Jun 29 '20 07:06 fgroeger

5 Charts 0x28abf8630 BarLineChartViewBase.pinchGestureRecognized (BarLineChartViewBase.swift:611) 6 Charts 0x28ac0a5c0 BarLineChartViewBase.pinchGestureRecognized

have you changed anything? I didn't see such crash. Able to reproduce?

liuxuan30 avatar Jul 08 '20 01:07 liuxuan30

We had some more crashes from this, we figured out you still could use pinch to zoom, we thought we disabled this by pinchZoomEnabled = false. But we needed to set setScaleEnabled(false) to completely disable the behaviour.

fgroeger avatar Jan 28 '21 07:01 fgroeger

Happens for me when using the Magic Keyboard trackpad on iPadOS. Any solution?

isaranjha avatar Jul 22 '21 10:07 isaranjha

I'm facing the same problem when pinch zoom enabled. I found that, it will only crash when run as "Designed for iPad model", on iPhone is ok.

2022-05-26 10:28:34.836710+0800 PromAlert[99972:4853592] [General] -[UIPinchGestureRecognizer locationOfTouch:inView:]: index (1) beyond bounds (0).

any update? How did you solve this issue? @fgroeger many thanks.

mylovelycodes avatar May 26 '22 02:05 mylovelycodes

I run into the same issue and none of the following (or all of it together at once) worked:

use_Line.pinchZoomEnabled = false use_Line.doubleTapToZoomEnabled = false use_Line.setScaleEnabled(false) use_Line.scaleXEnabled = false use_Line.scaleYEnabled = false

I was still able to scale and zoom by both double tapping and pinching when run as "Designed for iPad" was used.

zzpaf avatar Jun 09 '23 07:06 zzpaf