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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use old keyboardView reference for removing observer #157

Merged
merged 1 commit into from
Jun 1, 2023

Conversation

kirillzyusko
Copy link
Owner

@kirillzyusko kirillzyusko commented May 30, 2023

馃摐 Description

Use memoized keyboardView reference for removing observer.

馃挕 Motivation and Context

Since keyboardView is a getter there are some chances that it may return a new reference to a view when we access it.

In some cases it may be a problem, because it can return a reference to a view which doesn't contain an observer yet. As a result when we'll try to remove an observer from a view which doesn't have it -> we'll get a crash.

To prevent a crash in removeKVObserver we start to use _keyboardView instead of keyboardView. It'll give us an access to old view and we can safely remove the observer.

Fixes #155

Potentially also fixes: #152

馃摙 Changelog

iOS

  • use _keyboardView instead of keyboardView when remove observer;

馃 How Has This Been Tested?

Tested on iPhone 14 (simulator, iOS 16.2) using following code:

<Button title="show image picker" onPress={async () => {
  // You can also use as a promise without 'callback':
  const result = await launchImageLibrary();
}} />

馃摳 Screenshots (if appropriate):

Before After
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-05-30.at.16.55.42.mp4
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-05-30.at.16.54.08.mp4

馃摑 Checklist

  • CI successfully passed

@kirillzyusko kirillzyusko added 馃崕 iOS iOS specific 馃幆 crash Library triggers a crash of the app labels May 30, 2023
@kirillzyusko kirillzyusko self-assigned this May 30, 2023
@kirillzyusko kirillzyusko marked this pull request as ready for review May 31, 2023 12:22
@kirillzyusko kirillzyusko merged commit 9544e6b into main Jun 1, 2023
8 checks passed
@kirillzyusko kirillzyusko deleted the fix/155-image-picker-crash branch June 1, 2023 06:14
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
1 participant