From 7e15badf3c80f9bdd1897d1a03b3ffa26315111c Mon Sep 17 00:00:00 2001 From: orfelorfel23 Date: Sun, 31 May 2026 16:57:47 +0200 Subject: [PATCH] Fix expo-camera corrupting JPEG files on Android by using skipProcessing, lowering quality, and adding file flush delay --- src/screens/CameraScreen.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/screens/CameraScreen.tsx b/src/screens/CameraScreen.tsx index c519d87a..46acba7e 100644 --- a/src/screens/CameraScreen.tsx +++ b/src/screens/CameraScreen.tsx @@ -235,12 +235,16 @@ export default function CameraScreen({ console.log('Capturing from built-in camera fallback...'); if (expoCameraRef.current) { const photo = await expoCameraRef.current.takePictureAsync({ - quality: 0.95, - skipProcessing: false, + quality: 0.7, // Lower quality slightly to reduce file size and OOM risk + skipProcessing: true, // Crucial for Android tablets: prevents internal OOM that corrupts the image file }); capturedUri = photo.uri; rawWidth = photo.width; rawHeight = photo.height; + + // Wait 500ms to ensure the OS has completely flushed the file to disk. + // This prevents "Loading bitmap failed" when ImageManipulator reads it too fast. + await new Promise((resolve) => setTimeout(resolve, 500)); } else { throw new Error('Kamera-Referenz ist nicht verfügbar.'); }