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

Fix takeSnapshot not working on Android #961

Merged
merged 1 commit into from Apr 4, 2022

Conversation

Menardi
Copy link
Sponsor Contributor

@Menardi Menardi commented Apr 1, 2022

What

Calling takeSnapshot on Android throws an error that it needs to run on the main thread (#547).

Changes

This is similar to something I saw in the PR I made yesterday (#958). The fix is just to wrap the access of previewView.bitmap in a withContext to ensure it runs on the main thread.

Tested on

Android 9 emulator
Android 10 device

Related issues

Fixes #547

Accessing previewView.bitmap was throwing an error because it wasn't being done on the main thread.
Any access to previewView needs to be done on the main (UI) thread. This commit fixes the issue by
ensuring this access is now run on the main thread.

Fixes mrousavy#547
@mrousavy
Copy link
Owner

mrousavy commented Apr 4, 2022

Hey - thanks again for the PR man! LGTM 🚀

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

Successfully merging this pull request may close these issues.

🐛 takeSnapshot throws Not in application's main thread
2 participants