bitcraze / crazyflie2-ios-client

The Crazyflie 2.0 iOS client
36 stars 36 forks source link

Setting values for custom control sensitivity causes the app to crash #25

Open matthewspear opened 5 years ago

matthewspear commented 5 years ago

Steps to reproduce:

  1. Launch App
  2. Open settings
  3. Select "Custom" control sensitivity
  4. Edit Thrust value then edit yaw rate

The app crashes:

[Crazyflie_client.SettingsViewController endEditing:]: unrecognized selector sent to instance 0x7fbe71c04c30

Crazyflie client[35027:3951170] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Crazyflie_client.SettingsViewController endEditing:]: unrecognized selector sent to instance 0x7fbe71c04c30'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010fcb11bb __exceptionPreprocess + 331
    1   libobjc.A.dylib                     0x000000010f24f735 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010fccff44 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   UIKitCore                           0x0000000118ad8b4a -[UIResponder doesNotRecognizeSelector:] + 287
    4   CoreFoundation                      0x000000010fcb5ed6 ___forwarding___ + 1446
    5   CoreFoundation                      0x000000010fcb7da8 _CF_forwarding_prep_0 + 120
    6   UIKitCore                           0x0000000118aabecb -[UIApplication sendAction:to:from:forEvent:] + 83
    7   UIKitCore                           0x00000001184e70bd -[UIControl sendAction:to:forEvent:] + 67
    8   UIKitCore                           0x00000001184e73da -[UIControl _sendActionsForEvents:withEvent:] + 450
    9   UIKitCore                           0x0000000118dc37f7 -[UITextField _resignFirstResponder] + 155
    10  UIKitCore                           0x0000000118ad824e -[UIResponder _finishResignFirstResponder] + 286
    11  UIKitCore                           0x0000000118dc3416 -[UITextField _finishResignFirstResponder] + 48
    12  UIKitCore                           0x0000000118ad82fd -[UIResponder resignFirstResponder] + 140
    13  UIKitCore                           0x0000000118dc32a0 -[UITextField resignFirstResponder] + 147
    14  UIKitCore                           0x0000000118ad7f76 -[UIResponder becomeFirstResponder] + 655
    15  UIKitCore                           0x0000000118f7d2d5 -[UIView(Hierarchy) becomeFirstResponder] + 145
    16  UIKitCore                           0x0000000118dc1fa8 -[UITextField becomeFirstResponder] + 237
    17  UIKitCore                           0x0000000118d8115a -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 208
    18  UIKitCore                           0x0000000118d6df01 -[UITextSelectionInteraction oneFingerTap:] + 3851
    19  UIKitCore                           0x0000000118681b81 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 57
    20  UIKitCore                           0x000000011868aa5f _UIGestureRecognizerSendTargetActions + 109
    21  UIKitCore                           0x0000000118688244 _UIGestureRecognizerSendActions + 305
    22  UIKitCore                           0x000000011868749c -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 858
    23  UIKitCore                           0x0000000118678f20 _UIGestureEnvironmentUpdate + 1329
    24  UIKitCore                           0x00000001186789ad -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 478
    25  UIKitCore                           0x000000011867871d -[UIGestureEnvironment _updateForEvent:window:] + 200
    26  UIKitCore                           0x0000000118ae878a -[UIWindow sendEvent:] + 4058
    27  UIKitCore                           0x0000000118ac6394 -[UIApplication sendEvent:] + 352
    28  UIKitCore                           0x0000000118b9b5a9 __dispatchPreprocessedEventFromEventQueue + 3054
    29  UIKitCore                           0x0000000118b9e1cb __handleEventQueueInternal + 5948
    30  CoreFoundation                      0x000000010fc16721 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    31  CoreFoundation                      0x000000010fc15f93 __CFRunLoopDoSources0 + 243
    32  CoreFoundation                      0x000000010fc1063f __CFRunLoopRun + 1263
    33  CoreFoundation                      0x000000010fc0fe11 CFRunLoopRunSpecific + 625
    34  GraphicsServices                    0x00000001160d11dd GSEventRunModal + 62
    35  UIKitCore                           0x0000000118aaa81d UIApplicationMain + 140
    36  Crazyflie client                    0x000000010df593b7 main + 71
    37  libdyld.dylib                       0x0000000112576575 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

The endEditing selector is missing:

screenshot 2018-12-26 at 19 02 56

I've searched the code and can't see how this is supposed to work.

In the SettingsViewModel there are methods for:

func didUpdate(pitch: Float) -> Float? func didUpdate(yaw: Float) -> Float? func didUpdate(thrust: Float) -> Float?

But they aren't called anywhere...

Can anyone explain why this is the case? Am I missing anything?

I think the most obvious thing to do is create new actions for the 3 UITextFields and call the ViewModel from there or implement UITextFieldDelegate.

ataffanel commented 5 years ago

I could verify the bug on master. It does not exists in the app store release so it has been introduced since this point. If you have a fix please feel free to push a PR :-).