Skip to content

Crashes on iOS 15 #93

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

Closed
OmgDef opened this issue Oct 28, 2022 · 5 comments · Fixed by #359
Closed

Crashes on iOS 15 #93

OmgDef opened this issue Oct 28, 2022 · 5 comments · Fixed by #359
Assignees
Labels
🐛 bug Something isn't working 🎯 crash Library triggers a crash of the app 🍎 iOS iOS specific

Comments

@OmgDef
Copy link

OmgDef commented Oct 28, 2022

The app crashes right before keyboard is shown on iOS 15. On iOS 16 it works just fine.
Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value

Smartphone (please complete the following information):

  • Desktop OS: MacOS 12.6.1
  • Device: iOS Simulator
  • OS: iOS 15.0
  • RN version: 0.70.4
  • RN architecture: old
  • JS engine: Hermes
  • Library version: 1.4.0

Снимок экрана 2022-10-28 в 17 40 57

@OmgDef OmgDef added the 🐛 bug Something isn't working label Oct 28, 2022
@kirillzyusko
Copy link
Owner

@OmgDef it happens exactly on iOS 15.0? Nor 15.6 - exactly 15.0?

I'm asking because i've tested app on iOS 15.6 and everything worked correctly 🤷‍♂️

@OmgDef
Copy link
Author

OmgDef commented Oct 30, 2022

@kirillzyusko I could not repeat the issue on a fresh project. It seems there is a conflict with one of my dependencies.

@OmgDef OmgDef closed this as completed Oct 30, 2022
@kirillzyusko
Copy link
Owner

@OmgDef okay, let me know if you find a conflict and don't hesitate to re-open this issue or create a new one 🙂

kirillzyusko added a commit that referenced this issue Nov 4, 2022
## 📜 Description

Added optional chaining instead of forced unwrapping. Fixes crash
described in
#93

## 💡 Motivation and Context

In fact it's not a fix and is more avoiding NPE rather than a full fix.
But anyway, missing animation is better, than a crash of application
🤷‍♂️

## 📢 Changelog

### iOS
- avoid usage of forced unwrapping

## 🤔 How Has This Been Tested?

Tested locally on:
- iPhone 13 Pro (iOS 15.0);

## 📝 Checklist

- [x] CI successfully passed
@kirillzyusko kirillzyusko added the 🍎 iOS iOS specific label Feb 28, 2023
@kirillzyusko kirillzyusko added the 🎯 crash Library triggers a crash of the app label May 22, 2023
@bcgilliom
Copy link
Contributor

We had one user hit this on an iphone 15 Max, iOS 17.2.1. We are using version 1.10.3 of RNKC:

Thread 0 - (TH_STATE_WAITING)
0  Trusted +0x5746c0        Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value (KeyboardMovementObserver.swift:109:65)
1  Trusted +0x5705cc        KeyboardMovementObserver.observeValue(forKeyPath:of:change:context:) (<compiler-generated>)
2  Foundation +0x99e54      _NSKeyValueNotifyObserver
3  Foundation +0x99cf0      _NSKeyValueDidChange
4  Foundation +0x99b20      -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:]
5  Foundation +0x99850      -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:]
6  Foundation +0x12cb94     __NSSetPointValueAndNotify
7  UIKitCore +0x615f4       -[UIView(Geometry) _applyISEngineLayoutValuesToBoundsOnly:]
8  UIKitCore +0x60e44       -[UIView(Geometry) _resizeWithOldSuperviewSize:]
9  CoreFoundation +0x353f0  ___NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__

@kirillzyusko
Copy link
Owner

@bcgilliom can you check if #359 fixes the problem?

kirillzyusko added a commit that referenced this issue Feb 19, 2024
## 📜 Description

Do not use force casting in swift - replaced with optional casting and
guard statements.

## 💡 Motivation and Context

In sentry one of library user seen this:

```bash
Thread 0 - (TH_STATE_WAITING)
0  Trusted +0x5746c0        Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value (KeyboardMovementObserver.swift:109:65)
1  Trusted +0x5705cc        KeyboardMovementObserver.observeValue(forKeyPath:of:change:context:) (<compiler-generated>)
2  Foundation +0x99e54      _NSKeyValueNotifyObserver
3  Foundation +0x99cf0      _NSKeyValueDidChange
4  Foundation +0x99b20      -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:]
5  Foundation +0x99850      -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:]
6  Foundation +0x12cb94     __NSSetPointValueAndNotify
7  UIKitCore +0x615f4       -[UIView(Geometry) _applyISEngineLayoutValuesToBoundsOnly:]
8  UIKitCore +0x60e44       -[UIView(Geometry) _resizeWithOldSuperviewSize:]
9  CoreFoundation +0x353f0  ___NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__
```

It was very random crash, but still - it's not a good practice to use
force casting and as a prof -> it produces a crash in certain cases.

So in this PR I replaced it with more safe operators.

Closes
#93 (comment)

## 📢 Changelog

### iOS

- do not force cast KVO values

## 🤔 How Has This Been Tested?

There is no way to test whether crashes are gone or not, but I think
they should gone (in worst case we will have a new stacktrace).

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 🎯 crash Library triggers a crash of the app 🍎 iOS iOS specific
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants