Skip to content

Conversation

@kirillzyusko
Copy link
Owner

📜 Description

Prevent crash when no first responder in keyboardWillShow.

💡 Motivation and Context

It happens because we can not find first responder when keyboardWillShow is triggerred:

image

Then we get NPE here (read absoluteY of nil):

image

And finally app crashes:

image

To fix this problem I've decided to add guard statement - there is no sense to execute code further if we don't have a reference to TextInput - no sense to store it in holder, no sense to add listeners/observers, substitute delegates etc.

📢 Changelog

iOS

  • check that first responder is actually present before executing the code that relies on its presence;

🤔 How Has This Been Tested?

Tested manually on iPhone 15.

📸 Screenshots (if appropriate):

Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-05-14.at.17.18.14.mp4

📝 Checklist

  • CI successfully passed
  • I added new mocks and corresponding unit-tests if library API was changed

@kirillzyusko kirillzyusko added 🍎 iOS iOS specific 🎯 crash Library triggers a crash of the app labels May 14, 2024
@kirillzyusko kirillzyusko self-assigned this May 14, 2024
@github-actions
Copy link
Contributor

📊 Package size report

Current size Target Size Difference
136075 bytes 136074 bytes 1 bytes 📈

@kirillzyusko kirillzyusko marked this pull request as ready for review May 14, 2024 15:21
@kirillzyusko kirillzyusko merged commit 02002e9 into main May 14, 2024
@kirillzyusko kirillzyusko deleted the fix/crash-when-no-first-responder branch May 14, 2024 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🎯 crash Library triggers a crash of the app 🍎 iOS iOS specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants