fix: Fix takeSnapshot not working on Android (#961)
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 #547
This commit is contained in:
parent
fe01295226
commit
3850491b9f
@ -22,7 +22,9 @@ suspend fun CameraView.takeSnapshot(options: ReadableMap): WritableMap = corouti
|
||||
camera.cameraControl.enableTorch(true).await()
|
||||
}
|
||||
|
||||
val bitmap = this@takeSnapshot.previewView.bitmap ?: throw CameraNotReadyError()
|
||||
val bitmap = withContext(coroutineScope.coroutineContext) {
|
||||
previewView.bitmap ?: throw CameraNotReadyError()
|
||||
}
|
||||
|
||||
val quality = if (options.hasKey("quality")) options.getInt("quality") else 100
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user