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

EmojiPopup.Builder.fromRootView() reads from the disk on the main thread #476

Closed
lukesleeman opened this issue Oct 14, 2020 · 2 comments
Closed

Comments

@lukesleeman
Copy link
Contributor

EmojiPopup.Builder.fromRootView() performs a read from the disk on the main thread. This is caused by the builder constructing a RecentEmojiManager in its constructor:

this.recentEmoji = new RecentEmojiManager(rootView.getContext());

The RecentEmojiManager then creates a shared preferences instance, which then causes the main thread disk read. In our case this causes problems as we are running with strict mode enabled, and we are building our own RecentEmoji instance, so we don't even use the one that gets made in the constructor.

There are a few ways we can address this issue. I think the most straightforward approach would be to modify the EmojiPopup.Builder so that the recentEmoji field is @Nullable then construct a RecentEmojiManager inside the build method if recentEmoji is still null. That way people can set their own emoji managers and manage the threading of any disk reads in whatever way suits them.

All up it seems like a pretty minor change. @vanniktech would you be happy to accept a PR along these lines? I could submit something.

@vanniktech
Copy link
Owner

Yes sure, PR sounds good.

@lukesleeman
Copy link
Contributor Author

I've submitted a small PR which fixes the issue #478

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