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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI animation freezing when calling any set functions in Android #640

Open
jja08111 opened this issue Jun 20, 2024 · 1 comment
Open

UI animation freezing when calling any set functions in Android #640

jja08111 opened this issue Jun 20, 2024 · 1 comment

Comments

@jja08111
Copy link

jja08111 commented Jun 20, 2024

The UI animation freezes for around 200-300ms when calling any set functions in Android.

Minimal reproducible example

HomeScreen.tsx

export default function HomeScreen() {
  return (
    <View>
      <TouchableOpacity onPress={() => KeyChain.setInternetCredentials('name', 'username', 'password')}>
        <Text>Set keychain</Text>
      </TouchableOpacity>
    </View>
  );
}

Problem

I think the encryptString function should be run on another thread because the stream handling method causes the UI thread to block.

/** Encrypt provided string value. */
@NonNull
protected byte[] encryptString(@NonNull final Key key, @NonNull final String value,
@Nullable final EncryptStringHandler handler)
throws IOException, GeneralSecurityException {
final Cipher cipher = getCachedInstance();
// encrypt the value using a CipherOutputStream
try (final ByteArrayOutputStream output = new ByteArrayOutputStream()) {
// write initialization vector to the beginning of the stream
if (null != handler) {
handler.initialize(cipher, key, output);
output.flush();
}
try (final CipherOutputStream encrypt = new CipherOutputStream(output, cipher)) {
encrypt.write(value.getBytes(UTF8));
}
return output.toByteArray();
} catch (Throwable fail) {
Log.e(LOG_TAG, fail.getMessage(), fail);
throw fail;
}
}

Thank you for your attention.

@lurdharry
Copy link

this is a very urgent issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants