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

Ethers create random freezes main thread in react native #4629

Open
valavanisleonidas opened this issue Feb 29, 2024 · 1 comment
Open

Ethers create random freezes main thread in react native #4629

valavanisleonidas opened this issue Feb 29, 2024 · 1 comment
Assignees
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6

Comments

@valavanisleonidas
Copy link

Ethers Version

6.8.1

Search Terms

No response

Describe the Problem

When calling ethers.Wallet.createRandom() in react native the ui freezes probavly because the calculations are done in the main thread. how can we solve that ?

React native version

"react-native": "^0.72.4",

Code Snippet

No response

Contract ABI

No response

Errors

No response

Environment

No response

Environment (Other)

No response

@valavanisleonidas valavanisleonidas added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Feb 29, 2024
@ricmoo
Copy link
Member

ricmoo commented Apr 10, 2024

There are features added in v6 specifically to address this by shimming out the JavaScript functions for native implementations. I plan to get a package up that makes all these shims available, but any help would be appreciates.

For example, the expensive part of .createRandom() is likely the sha2-512 operation, so you can use: ethers.sha512.register((data) => { return nativeImplementation(data); } where nativeImplementation is a function you provide that calls a JNI (or such) implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

2 participants