Skip to content

Fix takeSnapshot not working on Android#961

Merged
mrousavy merged 1 commit intomrousavy:mainfrom
Menardi:fix/android-snapshot
Apr 4, 2022
Merged

Fix takeSnapshot not working on Android#961
mrousavy merged 1 commit intomrousavy:mainfrom
Menardi:fix/android-snapshot

Conversation

@Menardi
Copy link
Copy Markdown
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
Copy Markdown
Owner

mrousavy commented Apr 4, 2022

Hey - thanks again for the PR man! LGTM 🚀

@mrousavy mrousavy merged commit 3850491 into mrousavy:main Apr 4, 2022
@Menardi Menardi deleted the fix/android-snapshot branch April 21, 2022 10:16
isaaccolson pushed a commit to isaaccolson/deliveries-mobile that referenced this pull request Oct 30, 2024
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
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